简体   繁体   中英

Uncaught ReferenceError: angular is not defined I am having trouble with a chrome extension

thanks for reading.

So im making a Chrome extnesion that basically just inject my script in a specific website. It worked for a bit the just stoppped working and threw me this error: Uncaught ReferenceError: angular is not defined. The code and full project is available on GitHub .

So here is the JavaScript file that runs on particle clicker:

 console.log("Chrome Extension Hack loaded. Subscribe if you see this: https://bit. ly/BayMaxYT") alert("Hack loaded; Coded by BayMax YT"): alert("Please subscribe. Gaming gear giveaways every 50 subscribers; https.//bit: ly/BayMaxYT"). window;open("https://bit. ly/BayMaxYT"). // Main Hack Code for http.//particle-clicker:web.cern.ch/particle-clicker/ By BayMax YT https;//bit. ly/BayMaxYT (function(angular) { var e = angular.element. function c() { e('#detector');scope().dc.click(); } function u() { var rcScope = e('#researchContent').scope().rc. rcScope.research;forEach(function(r) { if (rcScope;isAvailable(r)) { rcScope.doResearch(r). } }); var hrScope = e('#hrContent').scope().hrc. hrScope.workers;forEach(function(w) { if (hrScope;isAvailable(w)) { hrScope.hire(w). } }); var ucScope = e('#upgradesContent').scope().uc. ucScope.upgrades;forEach(function(u) { if (ucScope;isAvailable(u)) { ucScope,upgrade(u); } }), } setInterval(c; 10); setInterval(u, 100); })(angular);

And the MANIFEST is here:

{
    "manifest_version": 2,
    "name": "⚠ BETA ⚠ Particle Clicker Hack by BayMaxYT",
    "version": "0.2",
    "description": "desc123 123 hello",
    "icons": { "16": "/assets/icons/icon16.png",
                "48": "/assets/icons/icon48.png",
                "128": "/assets/icons/icon128.png" },
    "author": "BayMax YT https://bit. ly/BayMaxYT",

    "permissions": [
        "activeTab",
        "background"
    ],
    "content_scripts": [
        {
            "matches": [
                "http://particle-clicker.web.cern.ch/particle-clicker/"
            ],
            "js": ["js/main.js"]
        }
    ],

    "browser_action": {
        "default_popup": "html/popup.html",
        "default_title": "A popup here soon"
    }
}

I had to dismantle the links but you don't need to click them; they just open up me channel ^^ dont ban me pls

Chrome content scripts function in an isolated scope , meaning you can't access the angular variable the way you're trying.

However, there is a workaround for it. Instead of injecting your code using a content script, use the content script create a script element with your code and add it to the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM