Sorry, found answer by myself (at the bottom of question)
I'm implementing simple google chrome addon (shows alert on android market, for now), and i'm facing with problems. What do i have:
Manifest (see below)
Icon.png
2 JS files (jquery and mine)
css file
permissions seem to be ok
Contents of each:
Manifest:
{
"name": "My first app",
"version": "1.0",
"description" : "My frist app",
"browser_action":
{
"default_icon": "icon.png"
},
"permissions":
[
"https://market.android.com/*"
],
"content_scripts":
[
{
"matches": ["https://market.android.com/*"],
"css": ["styles.css"],
"js": ["scripts.js", "jquery.js"]
}
]
}
My css file:
*
{
color:gray !important;
}
Scripts.js file:
$(document).ready(function() {
alert("!");
});
Jquery version is 1.7.1.
And now comes the sugar:
All items on android market are grayed. But no alert.
Thank you in advance, Nick.
OMG!
Just needed jquery before my script running. Sorry.
you need to load jquery in your manifest before your script
Related
I'm currently migrating from Manifest v2 to Manifest v3 for a chrome extension. My extension uses public API served over HTTPS. I use a local instance of that API to test my extension which is served at https://0.0.0.0:8080/. However, for reasons I cannot understand, my extension fails to fetch anything from this URL. and the error displayed on the service worker's log is
TypeError: Failed to fetch
If I switch my local API to be served at http://0.0.0.0:8080/, then the extension works fine. So basically, the extension works fine with all API URLs except for https://0.0.0.0:8080/ on Manifest v3. I tried switching back to Manifest v2 and it worked so I'm not sure why it doesn't work on v3.
My manifest file looks like this
{
"name": "...",
"description": "...",
"manifest_version": 3,
"version": "1.0.0",
"icons": {
"16": "icon16.png",
"48": "icon48.png",
"128": "icon128.png"
},
"action": {
"default_icon": {
"16": "icon16.png",
"48": "icon48.png"
},
"default_title": "..."
},
"background": {
"service_worker": "background.js"
},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*"],
"js": ["content.js"],
"css": ["App.scss"]
}
],
"permissions": ["storage"],
"host_permissions": ["http://*/*", "https://*/*", "*://*/*"],
"web_accessible_resources": [
{
"resources": ["App.css"],
"matches": ["http://*/*", "https://*/*"]
}
]
}
I've encountered the same problem. It turns out that if you open the workers console and view the fetch request it says that the error is ERR_CERT_AUTHORITY_INVALID. Unfortunately I have no idea why the transition to Manifest V3 causes this (the local host is served via Flask with a self signed certificate which is not a problem in Manifest V2).
Edit: registered this as a bug at Chromium: https://bugs.chromium.org/p/chromium/issues/detail?id=1395343
I have an extension that I've written for chrome. I recently decided I wanted to port it over to firefox, and I was surprised on how many things worked out of the box with no changes at all. However, one thing that has tripped me up is that for some reason my gmail.js content script is not being loaded. This is my content script:
{
"name": "Copy Machine",
"description": "Copies text more better",
"version": "0.6",
"permissions": ["contextMenus", "tabs"],
"icons": {
"16": "icon_16.png",
"32": "icon_32.png"
},
"background": {
"scripts": ["background.js"]
},
"manifest_version": 2,
"content_scripts": [
{
"matches": [
"*://mail.google.com/*"
],
"js": ["gmail.js"],
"run_at": "document_idle"
},
{
"matches": [
"<all_urls>"
],
"js": ["generic.js"],
"run_at": "document_idle"
}
]
}
The first line of my gmail.js content script is:
console.log("GMAIL SCRIPT IS RUNNING");
And the first line of my generic.js content script is:
console.log("GENERIC SCRIPT IS RUNNING");
When I open my gmail account in firefox, in the console I see "GENERIC SCRIPT IS RUNNING", but not "GMAIL SCRIPT IS RUNNING."
With google chrome, this works as I would expect, but for some reason the URL pattern isn't matching. Is there something I am missing? Thanks.
So I ended up adding "*://mail.google.com/*" to the permissions in the manifest file, and that got things working the way I expected. I then had to fix a few other bugs with apis that were not available, this is what I should have started with:
https://extensionworkshop.com/documentation/develop/porting-a-google-chrome-extension/
I then went back to file a bug report, and when I remove "*://mail.google.com/*" it's continues to work. So maybe there's some weird circular dependency thing going on? I'm not sure.
I created a chrome extension, which works fine when it is unpacked. Whether in Normal mode and Incognito mode too.
But when I pack the extension using "Pack Extension" feature of Chrome to pack the extension. Produced crx (packed extension) is once gets installed on Chrome, but when either
I disable the extension, or
Click on option "Allow in Incognito" http://i.imgur.com/zMxyN8T.png
Then, the Extension never gets activated until I remove the extension from chrome and reinstall.
On clicking the Enable checkbox it seems that it is activated but when you refresh the page, you'll see that extension is still deactivated, http://i.imgur.com/g09Ay7t.png
Any resolutions?
Edit:
I Saw the console:
Here is the error on clicking the checkbox:
Unchecked runtime.lastError while running management.setEnabled: Extension bdkngoljejekigejmcekcpghahpgljop cannot be modified by user.reportIfUnchecked # extensions::lastError:133handleResponse # extensions::sendRequest:78
Menifest:
{
"name": "TEST MAIN",
"version": "1",
"manifest_version": 2,
"description": "TEST MAIN",
"browser_action": {
"name": "Manipulate DOM",
"icons": ["images/icon.png"],
"default_icon": "images/icon.png"
},
"content_scripts": [
{
"matches": [ "http://*/*", "https://*/*" ],
"js": [ "js/jquery.min.js", "js/main.js" ],
"css" : ["all.css"],
"all_frames": true
}
],
"web_accessible_resources": [
"js/main.js"
]
}
I am trying to write a Chrome extension using Dart. So far everything goes well except for the content script --- the "main" function in the content script dart file does not seem to run.
To be more specific, first of all Dartium cannot be used since giving a dart file in the "js" rule in the manifest caused Dartium to complain; I next tried to compile the dart file (with csp: true) then make the manifest to include the compiled js file directly --- then I'm stuck, it seems that no matter what I try, the (compiled) "main" function just does not run.
Any suggestions?
Update:
The manifest file:
{
"manifest_version": 2,
"name": "Assistant",
"description": "Assists you with various tasks.",
"version": "1.0",
"minimum_chrome_version": "26.0",
"permissions": ["<all_urls>", "storage"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": [
"packages/browser/dart.js",
"dart_content_script.dart.js"
],
"run_at": "document_start",
"all_frames": false
}
],
"browser_action": {
"default_popup": "popup.html",
"default_icon": "bulb.png"
},
"background": {
"page": "background.html"
}
}
The content script dart file:
void main() {
print('main done');
}
The pubspec.yaml:
name: AssistentExtension
dependencies:
browser: any
chrome: any
dev_dependencies:
unittest: '>=0.10.0'
transformers:
- $dart2js:
csp: true
In the Chrome developer console, I can find the string "main done" meaning that the "main" function is indeed included in the compiled js, but nothing is printed meaning it is not run.
I had the same problem like yours. At that time I looked into the console logs, a log saying chrome package is missing (but i don't know what cause it), so I manually added it back to build folder, then it worked so I can see my logs written in main().
When I run test_ext that come with official chrome pub, I get a different error message in console log, again I solved it and then the test_ext sample is running well too.
So, my advise is take a look at the console log, it might help. You can open console for extension by right click on popup UI of extension and select 'Inspect Element' to open it.
i'm trying to update my manifest version for my extension but it gave me this problem:
default locale was specified, but _locales subtree is missing.
this is my manifest.json file, can anyone tell me where is the problem and what can i do?
{
"name": "Selected Text",
"version": "0.1",
"manifest_version": 2,
"description": "Selected Text and some changes",
"default_locale":"en",
"browser_action": {
"default_title": "S. Text",
"default_icon": "online.png",
"default_popup": "popup.html"
},
"permissions": [
"tabs",
"chrome://favicon/",
"http://*/*",
"https://*/*"
],
{
"matches": ["http://*/*"],
"js": ["selection.js"],
"run_at": "document_start",
"all_frames": true
}
}
It sounds like you are missing the required _locales directory in your extension root. Since you are specifying a default_locale, you need to provide a _locales directory, inside of which lie your internationalization options. In your case, you would need to at least have a folder titled _locales/en, inside of which you have a messages.json file, inside of which you would set your specific parameters (see here for more information).
I got the same issue.
Its "default_locate": "en",.
But then there is still an error. So just leave it out.
Please check the file hierarchy. It should be something like below,
- manifest.json
- 📂 _locales 👈
- 📂 en
- messages.json
- 📂 es
- messages.json
- 📂 ...
- messages.json
Reference
chrome.i18n
manifest
messages.json
"default_locale":"en",
look at this code and think. you will get solution .