1 year ago
#348535
sagarpandya
How to run specific script for particular website and general script for other websites
This question is completely different from match-all-urls-except-certain-urls-in-chrome-extension. This question is to run a specific script on the website rather than excluding it completely.
I am developing a chrome extension that requires a specific javascript file for 1 site. Another javascript file for all the other websites.
Here is my manifest.json
file.
{
"name": "See World Colourful",
"version": "0.0.1",
"manifest_version": 2,
"icons": {
"128": "logo.png"
},
"page_action": {
"default_popup": "popup.html",
"default_icon": "logo.png",
"default_title": "SeeWorldColourful"
},
"background": {
"scripts": ["eventPage.js"],
"persistent": false
},
"content_scripts": [
{
"matches": ["https://www.geeksforgeeks.org/*"],
"js": ["contentGFG.js", "jquery-3.6.0.js"]
},
{
"matches": ["https://*/*"],
"js": ["contentAll.js", "jquery-3.6.0.js"]
}
],
"permissions": [
"activeTab",
"tabs",
"storage",
"contextMenus",
"https://www.geeksforgeeks.org/*",
"https://*/*"
]
}
I was trying to run the contentGFG.js
script on geeksforgeeks website and the contentAll.js
script for all the other websites but, contentAll.js
runs on all the websites including geeksforgeeks.
javascript
google-chrome-extension
manifest.json
chrome-extension-manifest-v3
0 Answers
Your Answer