Content Script fails to run when navigating to a new link

Viewed 643

I am currently writing a Google chrome extension that needs to run on YouTube videos. I have a content script which is a JavaScript file that does all the work I need it to do.

It is working fine, the only caveat is that for some reason, whenever you click a link to go to a new video, it doesn't run the JavaScript code immediately; you need to reload the page to make it work.

manifest.json

{
"name": "Title",
"description": "description",
"version": "0.5",
"permissions": [
    "webNavigation",
    "activeTab",
    "tabs",
    "*://*.youtube.com/*"
],
"browser_action": {
      "default_icon": {                   
        "16": "image.png"         
      },
      "default_title": "name",      
      "default_popup": "popup.html"        
},

"content_scripts": [
{
  "matches": ["*://*.youtube.com/*"],
  "js": ["blocker.js"],
  "run_at": "document_end"
}
],
"manifest_version": 2
}

blocker.js

myfunction();
function myfunction(){
    //manipulate the HTML DOM
}
1 Answers
Related