Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome Extension background scripts aren't being loaded

My chrome extension background script is not being loaded. I followed Googles guide for them but still nothing. I'm not sure if there is another way to check but it isn't in Inspect Element and what the script should be doing isn't happening.

http://developer.chrome.com/extensions/background_pages.html

manifest.json file

{
"manifest_version": 2,

"name": "WebDevFriend",
"description": "blah blah blah",
"version": "1.0",

"permissions": [
    "bookmarks",
    "tabs",
    "http://*/*"    ],  

"background": {
    "scripts": ["js/settings.js"],
},

"browser_action": {
    "default_icon": "images/icon.png",
    "default_popup": "html/popup.html"
}
}

settings.js file

chrome.windows.onCreated.addListener(function(window){
  chrome.windows.getAll(function(windows){
      var length = windows.length;
      if (length == 2) {
          chrome.tabs.executeScript(null, {file: "content_script.js"});
      }
  });
});
document.write('hello');
like image 851
Dylan Buth Avatar asked Mar 10 '13 05:03

Dylan Buth


1 Answers

First you can't view the background page like a regular html page. The only way is to view its contents with the Chrome Developer Tools.

enter image description here

just click on generated_background_page.html in the extensions section of your browser.

Second use the console.log() statement to log messages.

like image 92
HaNdTriX Avatar answered Sep 28 '22 07:09

HaNdTriX