diff --git a/manifest.json b/manifest.json index ad6da4e..fe509c8 100644 --- a/manifest.json +++ b/manifest.json @@ -35,7 +35,7 @@ "content_scripts": [ { "matches" : ["https://intel.ingress.com/*"], - "run_at": "document_start", + "run_at": "document_end", "js": ["scripts/loader.js"] } ], diff --git a/scripts/loader.js b/scripts/loader.js index 00f8ed6..4ddc0ac 100644 --- a/scripts/loader.js +++ b/scripts/loader.js @@ -42,11 +42,14 @@ function getPlayerData() { } function preparePage() { - document.addEventListener("DOMContentLoaded", function() { - window.onload = function() {}; - document.body.onload = function() {}; - getPlayerData(); - }); + + let injectCode = "window.onload = function() {}; document.body.onload = function() {};"; + + let script = document.createElement('script'); + script.textContent = injectCode; + (document.head||document.documentElement).appendChild(script); + + getPlayerData(); document.addEventListener('IITCButtonInitJS', function (e) { let code = e.detail; @@ -67,7 +70,7 @@ function preparePage() { } chrome.storage.local.get(["IITC_is_enabled"], function(data) { - if (data["IITC_is_enabled"]) { + if (data["IITC_is_enabled"] !== false) { preparePage(); } -}); \ No newline at end of file +});