I am trying to get display information in my chrome extension. I was very successful to get it in manifest version 2 with "system.display" permission.
The API I used,
chrome.system.display.getinfo((info)=>{
console.log(info);
}
);
I am trying the same in manifest version 3, but it's giving me the error.
TypeError: Cannot read property 'display' of undefined
My manifest file,
"content_security_policy": {
"extension_pages": "script-src 'self'; object-src 'self'"
},
"host_permissions": ["<all_urls>"],
"permissions": ["activeTab", "tabs", "history", "storage", "system.display"]
Please help me to find out where I am making mistake.
One more thing, I read something like availability: foreground only, in a document of chrome.system.display API. If someone can explain what that exactly means then it'll be great knowledge you share with me.
Thanks
Related
I have a chrome extension I have made and I want to convert it to Edge using the Microsoft Edge Extension Converter, everything works fine except for the popups tabs and cookies permissions
"content_scripts": [
{
"matches": [
"http://www.website.com/*"
],
"js": [
"jquery-3.1.1.min.js",
"startup.js",
],
"css": [
"font-awesome.css"
],
"run_at": "document_end",
"permissions": [
"cookies",
"tabs"
]
}
],
If i were to remove
"permissions": [
"cookies",
"tabs"
]
The extension will load however the communication between the popup and the window will not work, but if i leave the code in i get the following error
Manifest parsing error: Invalid field 'permissions' found in 'content_scripts'.
I try to check the documentation and find that permissions are not the part of content_scripts.
In your sample above, I can see that you are using permissions under content_scripts.
I think this is the cause for this issue.
As per the documentation, following keys can be used with content_scripts.
all_frames, css, exclude_globs, exclude_matches, include_globs, js, match_about_blank, matches, run_at
to get the example refer link below.
content_scripts
To solve the issue, you can try to put 'permissions' outside the 'content_scripts'.
Reference:
permissions
I'm trying to load an extension, which was originally developed for Chrome, into Firefox. I'm aware that there are subtle differences, my idea was to fix the errors one by one.
The manifest can actually be loaded, an icon is added and the extension is listed as installed.
But during the loading, there are two warnings. One of them is:
Reading manifest: Error processing content_scripts.0.permissions: An unexpected property was found in the WebExtension manifest.
Unfortunately, this doesn't tell me which property is unexpected. I opened the debug consoles, the message is identical, there is no additional information.
The content_scripts section from the manifest is this:
"content_scripts": [
{
"css": [
"extra.css",
"all.css",
"bootstrap.min.css"
],
"js": [
"firebase.js",
"jquery.min.js",
"content.js",
"popper.min.js",
"bootstrap.min.js"
],
"matches": [
"https://dlab.epfl.ch/*",
"https://*.wikipedia.org/*"
],
"permissions": [
"storage",
"activeTab"
]
}],
The permissions look good to me. I checked against the Mozilla docs here, to avoid something like a spelling mistake. But storage and activeTab are allowed as permissions.
How can I find out what this unexpected property is ?
For reference, here is the full manifest: https://pastebin.com/dkaNmZHk
As #wOxxOm said, it is a simple mistake in the JSON layout:
permissions should be top-level and not within content_scripts.
I need to have sandboxes totally secured, others more "relaxed".
I tried this in the manifest.json (doesn't work, but describes accurately what I need to do):
...,
"sandbox": [
{
"pages":[
"sandbox1.html"
],
"content_security_policy": "<strict csp...>"
},
{
"pages":[
"sandbox2.html"
],
"content_security_policy": "<relaxed csp...>"
}
]
Unfortunately, I cannot find a way to have more than one content security policy for sandboxed pages.
The documentation shows how to implement the same CSP for multiple sandbox pages, but not how each sandbox could have its own CSP.
Is there any way to achieve this ?
Seems like it's not possible; "sandbox" is an object and can only have one "content_security_policy" key.
Sounds like an idea for a feature request.
Today my three Chrome extensions web developer accounts have been disabled and all my 30+ extensions are all taken down without even single warning email, but got the email stating that
"Where possible, make as much of your code visible in the package as
you can. If some of your app's logic is hidden and it appears to be
suspicious, we may remove it".
But, my extensions were containing only 2-3 javascript files, one is standard jquery js file, and other two are my own javascript files which have hardly 100+ lines of basic validation logic of javascript code. I am 100% sure that those are not at all malicious or suspicious code. I really don't know why Google has taken such ruthless action by suspending and taking down all extensions without even basic courtesy of informing to us.
I did get such complains from other friends who's accounts also got suspended and 100+ extensions are taken down. It is definitely seem to be a mass action.
If anybody facing same issue, please share your experience and any solutions to get everything back.
Regards
===== manifest.json =====
{
"manifest_version": 2,
"name": "Extension",
"version": "1.0.0",
"description": "Extension Description",
"icons": {"16": "img/icon-16.png", "48": "img/icon-48.png", "128": "img/icon-128.png"},
"background": {
"page": "background.html"
},
"browser_action": {
"default_icon": "img/icon-48.png",
"default_title": "Extension",
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": [ "http://*/*", "https://*/*"],
"js": ["js/jquery-1.9.1.min.js", "js/common.js", "js/popup.js"]
}
],
"permissions": ["*://*/*", "tabs", "webRequest", "webRequestBlocking", "notifications"],
"content_security_policy": "script-src 'self' 'unsafe-eval' https://ssl.google-analytics.com; object-src 'self'"
}
I am trying to replicate this demo code:
https://developers.google.com/fusiontables/docs/samples/circle_example?hl=en
which uses a FusionTablesLayer to query the data in the fusion table. Primarily
var layer = new google.maps.FusionTablesLayer({
query: {
select: 'lat',
from: tableid,
where: 'ST_INTERSECTS(lat, CIRCLE(LATLNG(44.988265,-93.259191), 5000))'
},
key: myKey
});
layer.setMap(map);
I have it working as a stand along page, with all the JS moved to another file, per the Chrome Extension guidelines. I have modified the manifest file to allow all the referenced servers in the content security policies setting.
{
"name": "GDG Twin Cities - Fusion Tables and Chrome extensions",
"version": "1.0",
"manifest_version": 2,
"content_security_policy": "script-src 'self' https://maps.google.com https://maps.gstatic.com; object-src 'self'",
"description": "Moving Fusion Tables demo into the chrome extension",
"browser_action": {
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"permissions": [
"https://maps.google.com/"
]
}
However I now get an error in the Console of
"Uncaught Error: Code generation from strings disallowed for this context "
How would I work with the FusionTablesLayer to get what I am looking for into my chrome extension?
There must be some eval() or new Function() used in fusion tables code. This is not allowed by CSP by default. Try one of these suggestions:
AngularJS (a JS framework from google) has something called "CSP mode" in which it does not use eval's. Maybe fusion tables have something similar?
Add unsafe-eval to your CSP as described in docs.
I ended up moving the functional browser action page to the web, and putting an iFrame in the popup.html.