2

i am creating a youtube chrome extension and try to load extension from background page automatically when any youtube video or channel page open but extension will not load untill i refresh same page again. i am using chrome.tabs.onUpdated.addListener to fire my script. i am already given tab permission on menifest.json file here is my background.js file is as

function checkForValidUrl(tabId, change, tab) {

if (change.status == 'loading' && change) {

//check for url is valid or not...and then load html through javascript

} }

chrome.tabs.onUpdated.addListener(checkForValidUrl);

thanks in advance.......

Vikas
  • 21
  • 3

1 Answers1

0

Detecting hash changes should work: WindowEventHandlers.onhashchange

I use it for checking to see if an email was opened in Gmail. Gmail also changes the URL similar to how Youtube does.

Example using your function name:

window.addEventListener("hashchange", checkForValidUrl, true);
Paul Hansen
  • 1,167
  • 1
  • 10
  • 23
  • Looks like Youtube uses a different method than Gmail. Possible duplicate question http://stackoverflow.com/questions/18397962/chrome-extension-is-not-loading-on-browser-navigation-at-youtube – Paul Hansen Oct 03 '15 at 05:51