0

I would like to access and modify a variable of a website from my chrome extension using JS. Opening the website and using console command (F12, Console) obviously it works, but I can't find a way to access from my JS. In this example, I am trying to get the length of Asset.image and it works on Console

enter image description here

But when I try to access it from JS using console.log(Asset.image.length); it says Uncaught ReferenceError: Asset is not defined

enter image description here

How can I access 'Asset' from JS? I just need to modify the variable for this session, if the user reloads the page everything goes back to normality.

I've also tryed to access using window.Asset but it returns undefined too from JS (it works from Console). It tryed also waiting until variable exists unsuccessfully. Also tryed to execute the command after a key pressed.

function waitForElement(){
    if(typeof Asset!== "undefined"){
        //variable exists, do what you want
    }
    else{
        setTimeout(waitForElement, 250);
    }
}

This is the fiddle https://jsfiddle.net/7pexgv1b/1/

How could I solve this? Thanks in advance.

Pitta
  • 1
  • 1

0 Answers0