I need to get the window.configData, variable that is inside a script tag. There are multiple script tags in my HTML code. But I need to get only the script tag that contains the window.configData variable. I know this can be done usingdocument.scripts / document.getElementsByTagName('script'), and searching for required variable.
I need to get this element in a single line, so as to pass it as variable to the content script in chrome extension. Below is the code of my content script.
function getPageDetails(jsonValueToFind, callback) {
chrome.tabs.executeScript({code:
"document.defaultView.configData"
}, function(result) {
var value = result[0];
chrome.tabs.query({currentWindow: true, active: true}, function(tabs) {
callback({
url: tabs[0].url,
title: tabs[0].title,
jsonValue: value
});
});
});
}
I need to pass this variable to the code section of content script. Can anybody suggest me how to acheive this