Kusha Kusha - 3 months ago 38
Javascript Question

Chrome extension Content Script not working

I built a Chrome Extension script that is supposed to run on Reddit.

My script:

console.log("hello world");


My manifest.json

{
"manifest_version": 2,
"name": "Name",
"description": "Desc",
"version": "1.0",
"browser_action": {
"default_icon": "icon.png"
},
"content_scripts": [
{
"matches": [
"*://reddit.com/*"
],
"js": [
"contentscript.js"
],
"run_at": "document_end"
}
],
"permissions": [
"tabs", "*://reddit.com/*", "activeTab"
]
}


The script doesn't show up in the "Content Script" section in the chrome dev tools. Does anyone have an idea why my extension is not running?

Answer

"*://reddit.com/*" doesn't match a valid url, you should use "*://*.reddit.com/*"