Eval() in chrome packaged app - eval

I need to use eval in my chrome app. is there any way to do this? It just needs to process a mathematical expression input.
I have tried adding unsafe-eval to the manifest, but it gives me an error a loading the app. Here is the manifest.
{
"name": "Calculator",
"description": "A calculator for Chrome.",
"version": "0.1",
"manifest_version": 2,
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": {"128": "calculator-128.png"}
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"
}

Read the Chrome documentation "Using eval in Chrome Extensions. Safely.". It answers this common question.

Related

How to add bootstrap to a web extension developed using React JS

I'm currently developing a wallet extension using ReactJS w/bootstrap, I'm trying to build the extension and test it on google chrome, but nothing is rendering.
I thought It might be because I'm using bootstrap and I must add some plugins or script in manifest.json. But I don't have any idea how to.
This is my manifest.json:
{
"manifest_version": 3,
"name": "Wallet",
"author": "whxy",
"version": "1.0.1",
"description": "E-Wallet",
"action":{
"default_title": "E-Wallet",
"default_popup": "index.html",
"default_icon":{
"16":"logo192.png",
"128":"logo192.png"
}
},
"permissions": ["storage"]
}

How can i append react index.html file when i click a chrome extension

I want to make a chrome extension using react. The problem I face I can't load the index.html file that is inside the public directory. My goal is when I click my chrome extension then the index.html file append inside the existing web page
This is my manifest.json code :
{
"name": "Demo Exe",
"description": "The demo chrome extension",
"version": "1.0",
"manifest_version": 2,
"permission": ["active"],
"permissions": ["storage", "activeTab", "scripting"],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["./index.js"]
}
]
}

Chrome storage API not accessible in React based chrome extension

I'm trying to use Chrome storage API to store access token after the user logs in the extension. However, when I try to use chrome.storage.local it throws error which says local was called on undefined.
I've added /* global chrome */ on the top of JS file in which I want to access the storage API. But the storage is still is not accessible.
As suggested in the documentation I've the storage permission added. Also, I've already tried multiple times to reload/reinstall the extension in chrome but the problem persists.
Following is my manifest file.
{
"manifest_version": 2,
"name": "My Extension",
"description": "This is My Extension",
"version": "1.0.0",
"homepage_url": "https://stylestash.dev",
"icons": {
"16": "ss-logo.png",
"48": "ss-logo.png",
"128": "ss-logo.png"
},
"browser_action": {
"default_icon": "ss-logo.png",
"default_title": "My Extension"
},
"background": {
"scripts": ["./jquery.js", "background.js"]
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"all_frames": false,
"js": ["./content.js", "./jquery.js"],
"run_at": "document_end"
}
],
"permissions": ["storage", "tabs", "activeTab", "<all_urls>"],
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"web_accessible_resources": ["index.html", "/static/*"]
}
Any help would be very appreciated. Thanks!

Cannot Access WebExtension APIs

I have the following manifest.json:
{
"manifest_version": 2,
"name": "Application Name",
"version": "1.0",
"description": "blah blah blah",
"icons": {
"48": "icons/icon-48.png",
"96": "icons/icon-96.png"
},
"permissions": [
"activeTab",
"tabs",
"history",
"storage"
],
"browser_action": {
"default_icon": "icons/icon-32.png",
"default_title": "Title",
"default_popup": "popup/popup.html"
},
"content_scripts": [{
"matches": [
"<all_urls>"
],
"js": [
"content_scripts/script1.js",
"content_scripts/script2.js"
]
}]
}
I have access to the the storage API (browser.storage is defined) in my content scripts, but both the history and tabs APIs (browser.tabs and browser.history) are undefined. Am I missing something in the manifest to get access to these permissions?
One of the few WebExtensions APIs that is available for content scripts is browser.storage. Most WebExtensions APIs can only be accessed when using a background script. Using message passing you can still call those APIs (what you do is basically calling a function in the background script from within the content script). Please see the example on this page: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/sendMessage
See also Firefox WebExtention API: TypeError: browser.browserAction is undefined for a similar problem.

Getting geolocation to work on ZTE Open C

it seems I can't get geolocation to work in FFOS 1.3.0. The default shipped "Here Maps" does Work but my App does not even ask for the Permission.
The Code does work on my Notebook, here I'm asked for the Location which is then provieded. I Guess it's the fault of the manifest file though I don't know what exactly is the Problem.
{
"version": "1.0",
"name": "Example",
"description": "Example",
"launch_path": "/index.html",
"icons": {
"16": "/images/icon_016.png",
"32": "/images/icon_032.png",
"48": "/images/icon_048.png",
"128": "/images/icon_128.png"
},
"developer": {
"name": "Example",
"url": "http://www.example.de"
},
"default_locale": "de",
"type": "privileged",
"permissions": {
"geolocation": {
"description": "Used to locate me"
}
}
}
Any help would be appriciated :)
I found the error. It seems to be needed to add
"installs_allowed_from": [
"*"
],
to the manifest file. My app does no ask for the permission and displays the location. Thank you all for your help :)

Resources