Skip to content

Commit

Permalink
Fix generating a many js errors in chrome #8
Browse files Browse the repository at this point in the history
  • Loading branch information
modos189 committed Sep 19, 2019
1 parent d5f559a commit 8ba8486
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"content_scripts": [
{
"matches" : ["https://intel.ingress.com/*"],
"run_at": "document_start",
"run_at": "document_end",
"js": ["scripts/loader.js"]
}
],
Expand Down
17 changes: 10 additions & 7 deletions scripts/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
});
});

0 comments on commit 8ba8486

Please sign in to comment.