Error loading extension - html

I got this extension for google chrome and it won't load when I try to load unpacked extension. Where is the problem?
{
"manifest_version": 2,
"name": "HTML",
"description": "HTML change",
"version": "1",
"background": {
"page": "background.html"
},
"content_scripts": [
{
"matches": ["https://ocjene.skole.hr/pocetna/prijava/*"],
}
],
}

Trailing commas mean invalid json - try this change first:
{
"manifest_version": 2,
"name": "HTML",
"description": "HTML change",
"version": "1",
"background": {
"page": "background.html"
},
"content_scripts": [
{
"matches": ["https://ocjene.skole.hr/pocetna/prijava/*"]
}
]
}

You may refer with this Can't load unpacked extension? forum.
I'm going to recommend that you start with a powerwash. This will wipe your device and return it to factory settings (and also put you back to the stable channel). Full instructions can be found in this help center article.
After the powerwash, I would suggest that you test whether or not the extension will load while still running a stable build. If it does, and then it stops working when you switch o the dev channel, that helps to narrow down the issue.
Additional references:
Load Unpacked Extension
Unable to load unpacked extensions

Related

Google App ID losing after upgrading NWJS to last version from 0.37.3

I have a legacy Google Chrome installable Apps packaged with NWJS as a standalone app.
I were using NWJS version 0.37.3 but now had to upgrade to last 0.56.0 because of Big Sur compatibility problems.
Now the problem is that the app generated with last NWJS sdk don't mantain old Google chrome app ID but got a new ID (testable in console with chrome.runtime.id).
So upgrading installed apps I were loosing old local data (local files, database, settings etc).
In manifest.json I have a "key" field with the app key that in old 0.37.3 was responsible to maintain chrome.runtime.id.
How I can keep using the same chrome.runtime.id with new NWJS SDK or any workaround to not loose existing local data?
My current manifest.json
{
"key": "MIGfM....B",
"name": "MyApp",
"description": "my app",
"version": "309",
"manifest_version": 2,
"default_locale": "en",
"nodejs": true,
"permissions": [
"<all_urls>",
"storage",
"browser",
"unlimitedStorage",
{
"fileSystem": ["write", "retainEntries", "directory"]
},
"videoCapture",
"nativeMessaging",
"webview"
],
"icons": {
"16": "images/favicon/favicon-16x16.png",
"128": "images/favicon/apple-icon-128x128.png"
},
"app": {
"background": {
"scripts": [
...
]
}
},
"chromium-args": "--ignore-certificate-errors",
"build": {
"appId": "my.app",
"nwFlavor": "sdk",
"output": "../package/",
"nwVersion": "0.56.0",
"outputPattern": "${NAME}-${VERSION}-${PLATFORM}-${ARCH}",
"targets": ["zip"],
"win": {
"icon": "images/favicon/win-app.ico",
"copyright": "..."
},
"mac": {
"icon": "images/favicon/mac/icon.icns",
"copyright": "..."
},
"nsis": {
"icon": "images/favicon/win-app.ico"
},
"excludes": ["**/bower_components", "**/bower_components/**/*"]
}
}
I'm not familiar with this, but seems like something that should be documented. I've created an open spreadsheet (anyone with link can edit), that documents all the versions of NW.js and their details. The data comes from the official versions list. And I've manually added the chrome.runtime.id's for some versions I had locally. I think some scripting will be needed to flesh out the rest of the versions, but at least there is now a public place for the info to go to.
https://docs.google.com/spreadsheets/d/16Y-mH5GzFL8BXLXCwzkvKQ7Vg4t4c2Jt6WgZaAAZPwc/edit?usp=sharing

Chrome extension REJECT when inline installation checked

I made custom chrome extension which loads external javascript file (file is hosted on amazon s3) using XMLHttpRequest. Code snippet which calls this XMLHttpRequest is in separate file, and included in manifest.json under content_scripts:
{
"background": {
"scripts": [ "background.js" ]
},
"content_scripts": [ {
"js": [ "content.js" ],
"matches": [ "http://*/*", "https://*/*" ]
} ],
"manifest_version": 2,
"name": "Name",
"short_name": "shortname",
"update_url": "https://clients2.google.com/service/update2/crx",
"version": "1.0"
}
If I don't check inline install, it is accepted and published in few minutes.
But when I check inline install and choose site, review process takes a long time and extension becomes rejected. Domain is secured (https). And tag containing info about extension is added to site's head tag.
<link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/itemID">
So, the rejection reason is probably related to inline installation method, and there should be some trick? Anyone for help? Is there something wrong I did?

Using chrome.runtime.sendmessage to communicate from a webpage to a packaged app

I'm trying to communicate from a web page to a packaged app. The idea is to have the web page read a number from a serial device. Because I want to access the serial device, I need a packaged app and can't use an extension. This is pretty similar to Keep Chrome Packaged App running in background? and it seems that Chrome documentation says this is possible.
How can I execute the chrome.runtime.sendMessage from a regular web page? When I do so, I get *Uncaught TypeError: Cannot read property 'sendMessage' of undefined. My simple function is:
function doFunction(){
chrome.runtime.sendMessage(editorExtensionId, {openUrlInEditor: url},
function(response) {
if (!response.success)
handleError(url);
});
}
My packaged app loads and can access the serial ports. But my suspicion is the manifest isn't "enabling" the chrome.runtime of the regular webpage. Manifest.json:
{
"name": "Hello World!",
"description": "My first Chrome App.",
"version": "0.1",
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": { "16": "calculator-16.png", "128": "calculator-128.png" },
"permissions": [
"serial",
"*://localhost/*"
],
"externally_connectable": {
"matches": [
"*://localhost/*"]
}
}
Maybe it's the ://localhost/ which I'm using for testing. But Chrome does not complain.
Any ideas out there? Thanks in advance.
Xan's comment did the trick.
While Chrome did not complain about *://localhost/*, it did not work. Chrome did complain about other combinations such as file://localhost/.
I added foo.com to host file and then served up my web page through a web server, and it worked! I can communicate from my web page to my packaged app.
Note that browsing to file://www.foo.com/hostpage.html did not work. But browing to http://www.foo.com:3000/hostpage.html did. (I'm using Rails, hence the 3000 port).
Morale of the story: When testing locally, you need to add an entry with a bogus second level domain to your host file.
Here's my manifest.json:
{
"name": "RFID Tag Reader",
"description": "Reads RFID Tags connected via USB reader",
"version": "0.0.0.1",
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": {
"16": "rfid-16.png",
"128": "rfid-128.png"
},
"permissions": [
"serial",
"*://www.foo.com/*",
"*://arealsite.net/*"
],
"externally_connectable": {
"matches": [
"*://www.foo.com/*",
"*://arealsite.net/*"
]
}
}
Adding "*://localhost/*" to externally_connectable worked for me.

Accessing the Cast API from within an extension page

I was working on a chromecast app, and I wanted to incorporate it into a chrome extension. I'm also using knockout.js in order to help with some of the UI. I have two pages, one is unsandboxed (http://jsfiddle.net/AuJaX/3/), and the other is sandboxed (http://jsfiddle.net/V2dJc/1/). None of the console.log's ever get called. My manifest is below:
{
"manifest_version": 2,
"name": "__MSG_app_title__",
"description": "__MSG_app_description__",
"version": "0.1",
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["js/content/content.js"]
}
],
"background": {
"scripts": ["js/back/background.js"],
"persistent": false
},
"permissions": [
"tabs",
"contextMenus"
],
"page_action": {
"default_title": "__MSG_app_title__",
"default_icon": {
"19": "images/icon-19.png"
}
},
"sandbox": {
"pages": ["sandboxed.html"]
},
"icons": { "48": "images/icon.png" },
"default_locale": "en"
}
Is there anything that I'm doing wrong, or is this something that's not supported (yet??)?
Did you whitelist the domain you are trying to use the extension on? Currently to have the Cast API injected into the page you need two things:
<html data-cast-api-enabled="true">
and you need to follow the steps at the bottom of this page (whitelisting in the extension, not the same as the Google Cast device whitelisting):
https://developers.google.com/cast/whitelisting#whitelist-chrome
That said, I doubt this is going to work. The instructions are for getting the Cast API injected into a regular web page. However, if I'm not mistaken you want the API injected into your Chrome extension page. I don't know if it will be made available there, since I don't think two different extensions are allowed to interact.

Google Chrome 'onLaunched' error in plugin

I am following the google chrome web app development on http://developer.chrome.com/trunk/apps/first_app.html and the web app is not launching. when i click on the app icon on the page it closes the tab. I have downloaded the sample apps and plugins from github but they too are not working when i look at the console i get this error, please not i have enabled experimental API's in chrome://flags.
Uncaught TypeError: Cannot read property 'onLaunched' of undefined
I have updated my chrome browser to version 22.0.1229.79. My manifest.json file is
{
"name": "Hello World!",
"description": "My first packaged app.",
"manifest_version": 2,
"version": "0.1",
"app": {
"background": {
"scripts": ["background.js"]
}
},
"icons": {
"16": "calculator-16.png",
"128": "calculator-128.png"
}
}
And my background.js file
chrome.app.runtime.onLaunched.addListener(function() {
chrome.app.window.create('window.html', {
'width': 400,
'height': 500
});
});
Can someone point me where am going wrong?
This error also occurs if you leave out the "app": {} declaration in the manifest.json.
I.e. "background": { "scripts": [ "background.js" ] },
Will give this error.
And "app": { "background": { scripts": ["background.js"] }, will work properly.
The new-style packaged apps (with the background key in the app section in the manifest) are only supported in Chrome 23 (currently in the dev channel, soon to be in the beta channel) and later.
Get a dev/beta copy of Chrome that is at least version 23.
I also had to add the following line to the manifest.json file before I could get the sample to run
{
...,
"minimum_chrome_version": "23",
...
}
You can follow the Chromium Development Calender here.