I am a noob trying to write a a Chrome extension. My JS (converted from Python) includes imports that apparently are only allowed in modules. From what I read this must be done in background. I cannot find how to do this properly in the manifest. This is the manifest I have but don't know where to go from here:
Edited Manifest
2nd edit and added JS
{
"manifest_version": 3,
"name": "Python Chrome Plugin",
"description": "This extension runs Python code.",
"version": "1.0",
"action": {
"default_icon": "icon.ico",
"type": "module",
"default_popup": "auto_select.html"
},
"permissions": [
"activeTab"
]
}
JS
import * as requests from 'requests';
import * as json from 'json';
var json_formatted_str, obj, url;
console.log("Getting page data")
Since this doesn't work (import only in module error), I don't know where to go next. The documentation on building a manifest is very poor (IMO). Can someone guide me through this? TIA.
Related
Recently, I have been working on a Chrome plug-in with co-workers and I must admit that I do not have much experience with Chrome extensions. We already published one version. Now, I just submitted a second release.
I am aware that following the Manifest v3 rules helps to speed up the review process. Also, I believe we are following the rules and we really need to have a fast review process.
However, I keep seeing this message:
It points to the official documentation on the topic: Migrating to Manifest v3 which includes a check-list.
This message makes me suspicious that I might have made some mistakes.
Hence, I would like to show my manifest.json:
{
"name": "My plug-in name",
"description": "Auto-fill some specific forms",
"version": "0.0.22",
"manifest_version": 3,
"action": {
"default_popup": "src/importer/popup.html",
"default_icon": "src/importer/img/company-logo.png"
},
"icons": {
"128": "src/importer/img/company-icon.png"
},
"permissions": ["activeTab", "scripting"],
"background": {
"service_worker": "src/importer/background.js"
},
"content_scripts": [
{ "js": ["src/importer/content-script.js"],
"matches": ["https://*.onewebsite.com/*"] }
]
}
It seems to be correct.
Am I missing something? Is the extension Manifest V3 compliant?
Should I ignore Chrome Web Store alert?
I built a small Chrome extension that works properly using the Chrome extension Manifest v2; however, support for v2 has been deprecated and updates must be published using Manifest v3.
Seems straightforward enough but Chrome throws an error when trying to load the unpacked extension with the new Manifest. Moreover, the error that it throws seems unrelated to the code I wrote and refers to one of the common libraries that I imported. The libraries I import include debounce for lodash, get from lodash, cheerio, and axios.
Here are both versions of the manifest followed by the error that Chrome throws when loading the extension via the new manifest.
Any pointers would be greatly appreciated. Thank you so much!
Manifest v2
{
"name": "LastBottle Price Checker",
"version": "1.0.0",
"description": "Fact-check the retail and web prices advertised on LastBottleWines.com by viewing crowd-sourced from consumers.",
"manifest_version": 2,
"icons": {
"128": "icon128.png"
},
"permissions": ["*://www.vivino.com/*", "*://api.vivino.com/", "unlimitedStorage", "activeTab"],
"content_scripts": [
{
"matches": ["https://www.lastbottlewines.com/*"],
"js": ["contentScript.js"]
}
],
"background": {
"scripts": ["bgScript.js"],
"persistent": false
}
}
Manifest v3
{
"name": "LastBottle Assistant",
"version": "1.0.0",
"description": "Fact-check the retail and web prices advertised on LastBottleWines.com by viewing crowd-sourced from consumers.",
"manifest_version": 3,
"icons": {
"128": "icon128.png"
},
"permissions": ["unlimitedStorage", "activeTab"],
"host_permissions": ["*://www.vivino.com/*","*://api.vivino.com/"],
"content_scripts": [
{
"matches": ["https://www.lastbottlewines.com/*"],
"js": ["contentScript.js"]
}
],
"minimum_chrome_version": "93",
"background": {
"service_worker": "bgScript.js",
"type": "module"
}
}
Error thrown by Chrome when loading unpacked extension
The first message is seemingly caused by the second...
I tried following Google's guide for migrating to Manifest v2, including the move from the background scripts to the service_worker framework. The service_worker conforms to the single JS file requirement and unchanged from the single JS file that worked properly when run in the previous manifest. The service_worker also meets the stated requirement of not interacting with the DOM.
Long time listener, first time caller...
I apologize if this has been answered, but I haven't been able to find it.
I'm having a grand ole' time trying to work with Chrome's developer dashboard. The lovely error messages are so vague that they give me just about no insight at all into the cause of the problem.
I just updated my extension 2 days ago - yes, I had a frustrating time of it, but it worked eventually. Well I overlooked a bug, which I quickly fixed, and now I'm trying to upload the new file. I followed the same procedure that worked before, which I found here: http://www.adambarth.com/experimental/crx/docs/packaging.html under "Uploading a previously packaged extension to the Chrome Web Store"
So my process is to: Pack the new extension files(including the manifest.json), add the .crx file to a folder, add the "key.pem" file to that same folder, compress said folder, and upload to the Chrome dashboard.
I'm aware that this process puts the manifest.json file in the packed .crx file and not in the root of the zipped folder that I'm trying to upload. Again, the above process worked before, and I've been trying in vain to repeat it today with no success.
The ONLY change made to my manifest file is the increment of the "version" number, as required.
I'm repeatedly getting the following:
An error occurred: Failed to process your item.
No manifest found in package. Please make sure to put manifest.json at
the root directory of the zip package.
My manifest.json, for whom it may concern...
{
"name": "AppName",
"version": "0.0.4",
"description": "App description - information was changed for stackoverflow post",
"manifest_version": 2,
"browser_action": {
"default_icon": {
"48": "img/pictureFile.png"
}
},
"background": {
"scripts": ["background.js"],
"persistent": false
},
"content_scripts": [{
"matches": ["*://linksRemovedForBrevity*"],
"js": ["content.js", "other-content.js"]
}],
"permissions": [
"activeTab",
"storage",
"tabs"
],
"web_accessible_resources": [
"styles.css",
"img/icon48.png"
]
}
I should mention that I'm a noob and don't know much of what I'm doing. Any and all help is greatly appreciated.
Cheers!
#wOxxOm got it. The extension doesn't need to be packed to be zipped and uploaded.
I was trying to incorporate something like Nicholas Cage into one of my projects related to google extension. My confusion is when I loaded the extension on google chrome, it seems that it did not load the jpg file related to Nicholas on my chrome. It supposed to work in the same way as the extension on the google chrome app store's Nicholas Cage. Here is my code for the nicholas cage. Here is my manifest json file:
{
"name": "Getting Started Example",
"version": "1.0",
"description": "Build an Extension!",
"content_scripts": [{
"js": ["ncage.min.js", "ncage.js"],
"matches": ["http://*/*", "https://*/*"]
}],
"manifest_version": 2}
I am trying to download a url by writing code for chrome extension. Here is the myscript.js file:
chrome.downloads.download(
{url: 'http://www.iana.org/_img/iana-logo-pageheader.png',
saveAs: true
},
function(res){alert(res);});
and here is my manifest.json
{
"name": "My extension",
"version": "1.0",
"manifest_version":2,
"background_page": "background.html",
"browser_action": {
"name": "Manipulate DOM",
"icons": ["icon.png"],
"default_icon": "icon.png"
},
"permissions": ["downloads",
"tabs", "http://*/*","https://*/*"
],
"content_scripts": [
{
"matches": [ "http://*/*", "https://*/*"],
"js": ["jquery.js","d3.v2.js","myscript.js"],
"run_at": "document_end"
}
]
}
but the console is showing the error "Cannot call method 'download' of undefined".
Please help me.
The documentation for chrome.downloads clearly states that the "API is still under development. It is only available for Chrome users on the dev early release channel." (emphasis mine, currently at Chrome 23).
To use the API, you need to get a dev or canary build of Chrome (see this page for download links).
Another way to solve the problem is by not using the chrome.downloads API. I've been using the following method to create downloads, and it works like a charm (it works anywhere: Content script / background page / popup / whatever):
var a = document.createElement('a');
a.href = 'http://www.iana.org/_img/iana-logo-pageheader.png';
a.download = 'iana-logo-pageheader.png'; // Filename
a.click(); // Trigger download
a.click() causes Chrome to follow the link.
The download attribute causes Chrome to download the target, and suggest the attribute's value as a file name in the Save As dialog.
This feature is not limited to Chrome extensions, you can also use it in an ordinary web page. Have a look at this demo: http://jsfiddle.net/dEeHF/.