I have a website which have an object stores in javascript variable, when I run images from web console this is the output:
Object {123: Array[3], 444: Array[3], 654: Array[3]}
I need to get this variable to my extension.
I tried using this code without success:
content.js:
function exeecuteCode(tab, code, callback) {
    chrome.tabs.executeScript(tab.id, {code}, response => {
        debugger;
    });
}
index.js:
(function() {
    document.addEventListener('DOMContentLoaded', () => {
        chrome.tabs.getSelected(null, tab => {
            executeCode(tab, "if (typeof images !== 'undefined') document.getElementsByTagName('body')[0].setAttribute('tmp_images', JSON.stringify(images));\n";);
        });
    }, false);
}());
My manifest.json includes the content.js file as follow.
manifest.json:
"content_scripts": [
    {
        "matches": ["<all_urls>"],
        "js": ["content.js"]
    }
]
I know how to retrieve back after i add the attribute to the body element.
The only thing that dowsn't work is the code above. I don't get any errors, and if I run the code in the tab console it works.
Thanks in advance for your help!
 
    