I am not sure why my jquery is not loading properly in my content script even though I have the jquery.js file under the resources in the web accessible resources. I keep getting this error: "ReferenceError: $ is not defined". Would appreciate any help, thank you.
manifest.json
{
"name": "Work Smarter",
"description": "Work Smarter - Elimanate Distractions, Be Productive",
"version": "1.0",
"manifest_version": 3,
"background": {
"service_worker": "background.js"
},
"permissions": ["storage", "activeTab", "scripting", "tabs"],
"action": {
"default_popup": "popup.html",
"default_icon": {
"16": "/images/16x16.png",
"32": "/images/32x32.png",
"48": "/images/48x48.png",
"128": "/images/128x128.png"
}
},
"icons": {
"16": "/images/16x16.png",
"32": "/images/32x32.png",
"48": "/images/48x48.png",
"128": "/images/128x128.png"
},
"web_accessible_resources": [
{
"resources": ["contentscript.css", "images/neverGiveUp.png", "jquery.js"],
"matches": ["<all_urls>"]
}
],
"host_permissions": ["http://*/", "https://*/*"]
}
Related
We're developing a web extension. We're actually trying to add some functionalities on the extension such as notifications.
For instance, we don't see any notifications at all, not even in the log console and we can't figure out the problem.
Do you have any ideas ?
Here is our manifest and our background.
Thank you in advance.
{
"description": "truc écolo",
"manifest_version": 2,
"name": "PolNum",
"version": "0.1",
"icons": {
"48": "icons/icon48.png"
},
"permissions": [
"webRequest",
"activeTab",
"http://*/*",
"https://*/*",
"tabs",
"*://*.google.com/",
"storage",
"alarms",
"history",
"notifications"
],
"browser_action": {
"default_popup" :"popup.html",
"default_icon": {
"16": "icons/icon16.png",
"32": "icons/icon32.png"
}
},
"background": {
"scripts": ["background.js"]
}
}
chrome.notifications.create('test', {
type: 'basic',
iconUrl: "icons/icon16N.png",
title: 'Test Message',
message: 'You are awesome!',
priority: 2
});
I have followed the steps to deploy the safari extension to mac app store by creating an archive and then validating it. I received no error when validating. However when trying to "Distribute App" The following error is coming up in the last stage. -"Corrupted manifest file. The manifest.json file could not be read in Safari extension bundle"
The extension build is running as per expectations locally.
Please help
My manifest.json
{
"author": "Author Name",
"background": {
"page": "index.html",
},
"version" : "1.0",
"browser_action": {
"default_icon": "assets/img/logo-64-disabled.png",
"default_title": "Title"
},
"content_scripts": [
{
"js": ["assets/js/index.js", "assets/js/content.js"],
"matches": ["<all_urls>"]
}
],
"content_security_policy": "script-src 'self' https://cdnjs.cloudflare.com; object-src 'self'",
"default_locale": "en",
"description": "Description",
"homepage_url": "https://example.com",
"icons": {
"128": "assets/img/logo-128.png",
"16": "assets/img/logo-16.png",
"32": "assets/img/logo-32.png",
"48": "assets/img/logo-64.png",
"64": "assets/img/logo-64.png"
},
"manifest_version": 2,
"name": "Name",
"options_ui": {
"open_in_tab": false,
"page": "assets/options.html"
},
"permissions": [
"contextMenus",
"tabs",
"activeTab",
"webNavigation",
"storage",
"<all_urls>",
],
"short_name": "Name",
"web_accessible_resources": ["assets/*"]
}
How can I run the content script without reloading the active tab?
The content script only works when I refresh the active tab.
Manifest.js
{
"name": "CMS",
"description": "A simple CMS solution that can update a website contents and images without modifying the current website structure.",
"options_page": "options.html",
"background": {
"page": "background.html"
},
"browser_action": {
"default_popup": "popup.html",
"default_icon": "icon48.png"
},
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*", "<all_urls>"],
"js": ["contentScript.bundle.js"],
"css": ["content.styles.css"]
}
],
"web_accessible_resources": [
"content.styles.css",
"icon128.png",
"icon48.png"
],
"manifest_version": 2,
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}
content_script
let paragraphs = document.querySelectorAll('*');
for (const elt of paragraphs) {
elt.style['border'] = '1px solid green';
}
I can't seem to inject it through a normal injection.
The code is the standard script of intercom put in an src/inject/inject.js file
Here is my manifest file
{
"name": "CHANGE THIS : Extension boilerplate",
"version": "0.0.1",
"manifest_version": 2,
"description": "This extension was created with the awesome extensionizr.com",
"homepage_url": "http://extensionizr.com",
"icons": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
},
"default_locale": "en",
"background": {
"page": "src/bg/background.html",
"persistent": true
},
"permissions": [
"https://*/*",
" http://*/*"
],
"content_scripts": [
{
"matches": [
"http://*/*", "https://*/*"
],
"js": [
"src/inject/inject.js"
]
}
]
}
{
"browser_action": {
"default_title": "Bot 2.0",
"default_icon": "logo.png",
"default_popup": "view/options.html"
I've been trying to make the popup feature to be activated, but every time I click on it nothing happens. Did I miss anything?
The problem is in the manifest.json file, you're writing 2 times browser_action property:
{
"browser_action": {
"default_title": "Bot 2.0",
"default_icon": { "38": "icon38by38pixels.png" },
"default_popup": "popup.html"
},
.....
"browser_action": {
"default_icon": "logo.png"
},
.....
}
You need to write the browser_action only once in the manifest.json:
{
"browser_action": {
"default_title": "Bot 2.0",
"default_icon": "logo.png",
"default_popup": "popup.html"
},
"background": {
"persistent": false,
"scripts": [ "view/jquery-1.9.1.min.js", "background.js" ]
},
"content_scripts": [ {
"js": [ "view/jquery-1.9.1.min.js", "supreme.js" ],
"matches": [ "*://*.supremenewyork.com/*" ],
"run_at": "document_start"
}, {
"js": [ "view/jquery-1.9.1.min.js", "checkout.js" ],
"matches": [ "*://*.supremenewyork.com/checkout/*" ],
"run_at": "document_end"
} ],
"description": "X",
"icons": {
"128": "logo.png",
"16": "logo.png",
"48": "logo.png"
},
"manifest_version": 2,
"name": "Bot 2.0",
"options_page": "view/options.html",
"permissions": [ "tabs", "*://*.supremenewyork.com/*" ],
"version": "1.0",
"web_accessible_resources": [ "view/jquery.min.map" ]
}