Search code examples
javascriptgoogle-chrome-extensiongoogle-chrome-devtoolscontent-script

Why can I not access objects on a website in content scripts?



I am working on a extension for Google Chrome, it will provide a refined experience when working with Glitch. Glitch has a object that I am able to access from the Developer Tools console called application, when I try to access it from the content script I get a element with an id of application instead of the JavaScript object that the console gives me. I am using this for my content script.

console.log(window.application);

Inside the console I just type the following (and it works).

application

I have two videos below that will show off my issue, the first one shows my ability to access application from the console, and my second one shows my code and the issue.

example 1

example 2


Solution

  • It turns out that you cannot access the window object at all, but their are some solutions located here.

    Access global js variables from js injected by a chrome extension Located by @romellem