chrome:// Invalid Scheme - javascript

I've enabled "chrome://flags/#extensions-on-chrome-urls" which should allow me to create extensions that can run on chrome:// sites. When I try to unpack my extension, however, it fails with the error message: "Invalid value for 'content_scripts[0].matches[0]': Invalid scheme." I don't believe my script.js is a problem since the unpacking doesn't fail when I replace the "chrome://extensions" part with an http or https sites. Any help would be greatly appreciated, does anyone know a fix?
manifest.json:
{
"name": "Does something on chrome://extensions",
"version": "1.2",
"description": "Read the name",
"manifest_version": 2,
"browser_action": {
"default_title": "Ext",
"default_popup": "popup.html"
},
"content_scripts": [ {
"matches": ["chrome://extensions"],
"js": ["script.js"]
} ]
}

Note: This is an undocumented feature and may fail without warning in the future.
chrome://extensions is an invalid match pattern. You cannot omit the path component, so at the very least you should use "chrome://extensions/*".
This does however not work either, because the actual URL is chrome://chrome/extensions. Or, if you are specifically interested in the page that shows the list of extensions, chrome://extensions-frame.
To run a content script at the extensions page, use --extensions-on-chrome-urls and:
"content_scripts": [{
"matches": ["chrome://chrome/extensions*"],
"js": ["script.js"]
}]
or (the frame that lists all extensions, i.e. what you see when you visit chrome://extensions):
"content_scripts": [{
"matches": ["chrome://extensions-frame/*"],
"all_frames": true,
"js": ["script.js"]
}]

Related

Manifest.json : What is wrong with this file? [duplicate]

This is my first attempt writing a Chrome extension. I added "web_accessible_resources": ["images/icon.png"] to manifest.json because I wanted to access the image from content script. After adding this line, I got the error "Invalid value for 'web_accessible_resources[0]'.
Could not load manifest." I have checked to make sure the file path is correct, where else could I be wrong?
Any help is appreciated.
{
"name": "Bookmark Checker",
"version": "1.0",
"manifest_version": 3,
"permissions": [
"bookmarks",
"activeTab"
],
"background": {
"service_worker": "background.js"
},
"content_scripts": [
{
"matches":["https://www.google.com/search?*"],
"js": ["content/content.js"]
}
],
...
"web_accessible_resources": ["images/icon.png"]
}
The syntax for web_accessible_resources in Manifest V3 has changed:
"web_accessible_resources": [{
"resources": ["/images/icon.png"],
"matches": ["<all_urls>"]
}]
The matches key must specify where to expose these resources since Chrome 89.

Permissions for simple text-replace Chrome extension?

I have an extension I've developed for Chrome (and Firefox, down the road), but can't get it to work when downloaded from the App Store. I think the problem is the permissions.
It's simple: the extension looks for particular text on a page (say: "dog") and highlights it. Just a simple HTML swap.
The .crx file includes the manifest and the javascript which does the replacement (and works locally). This is packaged with the icon and another version of the manifest (unless I'm doing something wrong here?) and submitted to the store. I tried various permissions (like "activetab") but it didn't work.
The three files are:
manifest.json (sits outside .crx)
{
"name": "[name]",
"version": "[version]",
"description": "[description]",
"manifest_version": 2,
"icons": {
"128": "icon_128.png"
},
"permissions": ["activeTab"],
"content_scripts":
[
{
"matches": ["<all_urls>"],
"all_frames": true,
"js": ["script.js"],
"run_at": "document_end"
}
]
}
manifest.json (sits inside the .crx)
{
"name": "[name]",
"version": "[version]",
"description": "[description]",
"manifest_version": 2,
"author": "[author]",
"permissions": ["activeTab"],
"content_scripts":
[
{
"matches": ["<all_urls>"],
"all_frames": true,
"js": ["script.js"],
"run_at": "document_end"
}
]
}
script.js (sits inside the .crx)
Runs the actual search and replace. Runs without issue locally.
What am I doing wrong? Pulling out my hair.

Published a new Chrome extension and when I am trying to download it to test, it is broken

So I tried to create a new Chrome extension for the Chrome web store, and everything seemed to upload and publish correctly.
However now when I try to load the page for the extension, it is broken.
Chrome gives me this error in the console:
POST https://chrome.google.com/webstore/ajax/detail?hl=en-US&gl=US&pv=20170811&mce=atf%2Cpii%2Crtr%2Crlb%2Cgtc%2Chcn%2Csvp%2Cwtd%2Cnrp%2Chap%2Cnma%2Cc3d%2Cncr%2Cctm%2Cac%2Chot%2Ceuf%2Cmac%2Cfcf%2Crma%2Crae%2Cshr%2Cesl%2Cigb&id=gpgcbiaclhpaiknckdfdpbjkdgfkimmo&container=CHROME&_reqid=706656&rt=j 404 ()
And I get the error message:
There was a problem loading the item. Please refresh the page and try again.
As far as I can tell, my manifest.json is correct:
{
"name": "Chinese Personalized Colors",
"version": "0.0.0.1",
"short_name": "CPC",
"manifest_version": 2,
"description": "Color code individual Chinese characters",
"options_ui": {
"chrome_style": true,
"page": "options.html"
},
"content_scripts": [
{
"matches": ["http://*/*", "https://*/*", "file:///*/*", "\u003Call_urls>"],
"css": ["mystyles.css"],
"js": ["jquery-1.7.2.min.js", "highlight_class_version.js", "content.js"],
"all_frames": true
}
],
"permissions": ["storage", "http://*/*"],
"background": {
"scripts": ["dict.js", "main.js", "background.js"]
},
"browser_action": {
"default_title": "CPC"
},
"icons": {
"128": "cpc-128px.png",
"48": "cpc-48px.png",
"16": "cpc-16px.png"
},
"author": "My Name",
"web_accessible_resources": ["css/*", "js/*", "images/*"]
}
All the images and all the files above exist in the zip uploaded to Google.
I tried logging out and logging back in as this was recommended advice by some people.
What could be wrong? Could it just be that the app hasn't been published for long enough to work correctly? The stack trace isn't really telling me much and I can't find any documentation on recent uploads causing an error like this anywhere.
It started working with no uploaded changes on my part. As far as I can tell, sometimes it takes time for an app to propagate to the Web Store, even when the listing appears.

Content script doesn't support chrome settings page (url : chrome://history/ etc. )

I am working with a chrome extension . I want to inject js script in all tab. I am using this manifest.json :
{
"name": "ABC",
"version": "0.0.1",
"manifest_version": 2,
"background": {
"scripts": [
"src/background/background.min.js"
],
"persistent": true
},
"browser_action": {
"default_icon": "icons/128.png",
"default_title": "ABC",
"default_popup": "src/browser_action/index.html"
},
"permissions": [
"tabs",
"http://*/*",
"https://*/*",
"<all_urls>"
],
"content_scripts": [{
"matches": ["<all_urls>"],
"js": ["./src/inject/inject.min.js"],
"css": ["./css/inject.min.css"],
"all_frames": true
}]
}
And my inject.js is like this :
(function() {
console.log("Hello");
});
I am getting all log from all tab except the tab of the chrome setting (eg : chrome://extensions/:id , chrome://history etc).
Am I missing something in manifest.json or chrome disables the feature of injection in settings page ?
Thanks in advance.
Indeed, you can't inject code into chrome:// pages. They contain control elements / code that can modify the browser in ways that an extension is not allowed to.
Chrome resolves this by simply not allowing permissions to be set for chrome:// URLs, and <all_urls> does not include it.
However, you could use Override Pages to replace some of them (well, History page at least) completely.

Can't xhr file inside of Chrome extension

I'm building out an extension and I'm trying to keep it well structured. Part of it will use a templating system of some type (Mustache, Handlebars, etc). Note that I'm already aware of having to use a specific non-eval version of what ever library I go with.
The problem is that from within the app.js script (the core logic) I cannot XHR to load the contents of the files in /templates (see below).
The load event never fires, and when I examine with onreadystatechange it immediate jumps to state 4 with a status code of 0. (state 4 and status 200 are what we want).
Getting the Chrome url for the file works, e.g.
chrome.extension.getURL('templates/view1.html')
//chrome-extension://hdhpjlpbepobcdgnkklnakdpoojaahjg/templates/view1.html
I suspect there's something in my manifest.json that isn't configured right. I've read through the CSP docs but nothing is jumping out at me why accessing files local to the extension should be denied. Note that the XHR requests don't throw errors, they just never return data.
The structure of the app is like this:
/manifest.json
/src
app.js
style.css
/libs
jquery.js
mustache.js
/templates
view1.html
view2.html
Manifest.json
{
"name": "Test Extension",
"version": "0.0.1",
"manifest_version": 2,
"icons": {
// "16": "",
// "48": ""
// "128": ""
},
// "default_locale": "en",
"permissions": [
"contentSettings",
"http://*/*",
"https://*/*"
],
"content_scripts": [
{
"matches": [
"https://www.google.com/search*"
],
"css": [
"src/style.css"
],
"js": [
"src/app.js",
"libs/jquery.js",
"libs/mustache.js"
],
"run_at": "document_start"
}
]
}
You need to list the files you want to load in a web_accessible_resources section in your manifest.

Categories

Resources