0

I am trying to access JS variables on some website with my Chrome extension

But that website using Require.js

I tried with :

Manifest.json

"content_scripts": [{
   "matches":["*://*.example.com/*"],
   "js":["src/inject/inject.js"],
   "run_at":"document_end"
}]

Inject.js

console.log(require); // not defined
console.log(requirejs); // not defined
console.log(jQuery); // not defined

window.onload = function() {
    setTimeout(function(){
        console.log(require); // not defined
        console.log(requirejs); // not defined
        console.log(jQuery); // not defined
    },5000);
};

Any trick ?

l2aelba
  • 21,591
  • 22
  • 102
  • 138
  • 1
    See https://stackoverflow.com/questions/17246133/contexts-and-methods-for-communication-between-the-browser-action-background-sc and https://stackoverflow.com/questions/9515704/building-a-chrome-extension-inject-code-in-a-page-using-a-content-script – Rob W Mar 14 '16 at 22:21
  • @RobW So thanks , I should accept your command as an answer :D – l2aelba Mar 14 '16 at 22:26
  • Which of the two provides the most helpful answer to your question? Then I'll mark your question as a duplicate of that, so that others who have a similar question as you will immediately be redirected to the duplicate. – Rob W Mar 14 '16 at 22:29
  • Yep do it. sorry that @RobW – l2aelba Mar 14 '16 at 22:29
  • 1
    No problem! Without knowing the answer you couldn't have known that the answer is already covered in depth in the other questions. Your clear question may help others in the same situation to find the answer more quickly. I think that you can vote to close the question as a duplicate of either question (because you have 3k+ rep). If you do that, then I'll also vote to close with the other question and then the question will be linked to these two other questions. – Rob W Mar 14 '16 at 22:33

0 Answers0