Addon only works on localhost


(Inamfdserv) #1

this is a very simple addon

manifest.json

{

  "manifest_version": 2,
  "name": "Borderify",
  "version": "1.0",

  "description": "Adds a red border to all webpages matching mozilla.org.",

  "icons": {
    "48": "icons/border-48.png"
  },

  "content_scripts": [
    {
      "matches": ["*://*.localhost/*"],
      "js": ["app.js"]
    }
  ]

}

app.js

document.body.style.backgroundColor = "red";
document.getElementById('foot').innerHTML = 'hi';
alert(1);

this works fine when i open localhost but when i change

      "matches": ["*://*.localhost/*"],

to

      "matches": ["*://*.stackoverflow/*"],

it wouldn’t work anymore when i open stackoverflow.com


(Niklas Gollenstede) #2

Well, if you want it to work on stackoverflow.com, you should use that domain in the match pattern ("matches": ["*://*.stackoverflow.com/*"]).


(Inamfdserv) #3

thanx , i thought using wild card doesnt need the full domain


(Niklas Gollenstede) #4

Nope. The wildcards in this pattern mean:

  • any protocol (http/https)
  • any subdomain (such as `www.) or no subdomain
  • any path/query/hash

You always have to specify the complete public suffix (TLD + the sprecific domain name in that TLD) (or wildcard to all domains).