javascript - tab.url.indexOf to check if URL contains specific string in an Extension -
i'm trying inject script webpage if current url contains specific string.
the webpage i'm trying on: http://s128-en.ogame.gameforge.com/game/index.php?page=galaxy
the background.js
chrome.tabs.onupdated.addlistener(function(id, info, tab){ if (tab.status !== "complete"){ return; } if(tab.url.indexof("galaxy") != -1){ chrome.tabs.executescript(tab.id, {"file": "findtarget.js"}); console.log("injected"); } });
for reason never injects script. missing here?
script working fine. reloading extension , reopening tab fixed problem.
javascript url google-chrome-extension get
No comments:
Post a Comment