I want to distribute a PNaCl app, inline installation and use the app without leaving the current page. I have published the app on CWS. The app needs some user permissions. Inline installation works and the app appears in the Chrome browser apps section. But, I get this error :
"NaCl module load failed: could not load manifest url"
when I try to load the app using:
<embed id="testapp"
width=0 height=0
src="testapp.nmf"
type="application/x-pnacl" />
This is the testapp.nmf file which is located in the .zip pkg that I uploaded to developers dashboard.
{
"program": {
"portable": {
"pnacl-translate": {
"url": "testapp.pexe"
},
"pnacl-debug": {
"url": "testapp_unstripped.bc"
}
}
}
}
Manifest.json in the package file looks like :
{
"name": "testapp",
"version": "0.0.0.2",
"manifest_version": 2,
"description": "TCP/UDP test",
"offline_enabled": true,
"icons": {
"128": "icon128.png"
},
"app": {
"background": {
"scripts": ["background.js"]
}
},
"permissions": [
{
"socket": [
"tcp-listen:*:*",
"tcp-connect",
"resolve-host",
"udp-bind:*:*",
"udp-send-to:*:*"
]
}
]
}
The HTML page is on Google's blogspot.com and verified successfully.
Observations:
You can't use socket APIs outside a packaged app (since there is no way to get permissions for them otherwise).
A packaged app is mostly self-contained: it's not something interacting with the normal browser, it's a preset collection of resources that is displayed in a separate window.
A certain website can still communicate with the app.
Seems like you're trying to follow two guides at once, for a packaged app and a web app. PNaCl can work in the context of a web app by just placing the pexe and the manifest on the site itself; but you require raw network access, and it can only be requested in a packaged app.
You can absolutely use inline install to add the app to the user's machine, but you can't embed a module from it in a normal page.
Your module can only be embedded in the app's own pages. So if you wanted to show some UI, you need to make that a page packaged together with the app and show it with chrome.app.window.create.
If you absolutely need to expose functionality to a certain website, you can list it in externally_connectable and use messaging API to communicate with the app's background page.
An app always has an event page, that is a page that unloads if it's idle. So if you just embed your module in that page by dynamically creating an <embed> element, it may fail. However, if you're using the externally_connectable method, you should be able to keep a port open, that would cause the page to keep running.
Related
I managed to get my PWA to complete all the chrome dev tools tests but I still cannot get an install prompt to fire.
www.billtravis.net/pwa/
from what I've seen everywhere the install prompt should fire when the manifest loads before the service worker installs.
This PW also needs to live on an IIS server, which won't even register the worker.
Any ideas?
{
"name": "SYLVANIA LightPRO",
"short_name": "LightPRO",
"icons": [
{
"src": "/img/image-512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": "/pwa/?homescreen=1",
"scope": "/",
"display": "standalone",
"background_color": "#ff6600",
"theme_color": "#ffffff"
}
Probably it due to lack of image sizes definitions in manifest.json which were required by web browser. I can see you have only 512 while different browsers expect a different set of images. So if you would not like to care about that differences in PWA implementation between the browsers, you can use pwacompat:
<script async src="path/to/pwacompat.min.js"></script>
This "polyfill" will generate all necessary images (if not specified in manifest.json) and will add metatags (required by ios for example)
I have a very simple chrome extension that refuses to run on some sites like https://mail.google.com. It runs fine on other sites which makes me think something is limiting extensions/scripts from running on some sites. The sample case is quite simple and listed below.
With this sample case I see "Hello world" in the developer console when I navigate to https://about.me. I also see the extension in the Developer Console's Execution Context Selector. However, when I navigate to https://mail.google.com I don't see the log entry or the extension in the Execution Context Selector.
I have tried something similar with tampermonkey and am not seeing that script run on gmail either. Thanks!
manifest.json:
{
"manifest_version": 2,
"name": "Gmail extension test",
"version": "0.1.9",
"description": "Try running inside gmail page",
"content_scripts": [{
"all_frames": true,
"js": ["content.js"],
"matches": [
"https://mail.google.com/*",
"https://about.me/*",
"http://*/*",
"https://*/*"
]
}]
}
content.js:
console.warn("Hello world");
Environment:
Chrome 66.0.3359.117
macOS 10.13.3 (17D102)
As #wOxxOm suggested. I tracked down the problem to the fact that my company has a Chrome policy set against running extensions on the google.com domain. I had no warning entries in the Developer Console or the macOS Console, I just tracked down other folks complaining about in an internal forum.
The policy that applies in this case is ExtensionSettings which is set in a OS/device specific way. To help diagnose this restriction, you can view your active polices in Chrome under chrome://policy/. In my case I had something like the following in my chrome://policy:
{
"*": {
...
"runtime_blocked_hosts": [ "*://*.google.com", ....]
},
I'm not aware of a generic workaround for this at the extension level. Instead I had to work with my company IT department to whitelist the extension.
I'm pretty new at chrome extensions and am trying to make a simple one that automatically launches links in my emails. I am going to modify it a bit later on, but for now, this is all I am trying to do. How do I have a chrome extension automatically read the text of the current tab that I am on, or when I open emails if I can get that specific? I have a manifest file set up and currently can make the extension button launch a link, but I'd rather have this happen automatically, as I don't want to hit a button to launch a link when I could just click the link itself.
manifest.json
{
"manifest_version": 2,
"name": "MT task launcher",
"description": "This extension launches Task Links in emails",
"version": "1.0",
"background": {
"scripts": ["task.js"]
},
"browser_action": {
"default_icon": "icon.png",
"default_title": "Email Task Launcher"
},
"permissions": [
"activeTab"
]
}
task.js
chrome.browserAction.onClicked.addListener(function(tab) {
var action_url = "http://www.reddit.com";
chrome.tabs.create({ url: action_url });
});
Take a look at Official Guide, for your purpose, I think you should use content scripts ( which are injected into current web page), then read the DOM and get all the links. To open the links, you can either call window.open() or by passing message then open them via chrome.tabs.create
There are two options to do that, it's either edit the local copy of the extension or to inject the call to the extension.
Inject code as a Content script, use the matching rules as defines in the manifest file
A background page file use the 'chrome.tabs.onUpdated' event. Also, use the 'chrome.tabs.executeScript' method to inject script.
The simplest Google Chrome apps seem to be those that just act as a bookmark or shortcut to a Web site. They have a manifest.json that is something like this:
{
"manifest_version": 2,
"version": "0.1",
"short_name": "stackoverflow",
"name": "stackoverflow shortcut",
"description": "stackoverflow bookmark chrome app",
"icons": { "128": "img/128.png" },
"minimum_chrome_version":"37.0.0.0",
"app": {
"urls": [ "http://stackoverflow.com/" ],
"launch": { "web_url": "http://stackoverflow.com/" }
},
}
The basics of this are documented in the Getting Started Tutorial Sample and in the Create a private Chrome app page this type of app appears to be referred to there as a bookmark app.
My questions are:
Is bookmark app is an official term for this kind of Chrome app? As I am having difficulty finding any other official place it is referred to in such a way
Where is manifest.json fully documented? The extension manifest.json documentation does not even contain info for the app name tag, and the main manifest.json doc doesn't mention the urls, launch, and web_url elements?
The tags are fairly self explanatory and used in many tutorials all over the Web but it seems odd there is no official documentation for them, especially when app is used for more complex Chrome apps - I just want to make sure I am not somehow missing some official and more complete documentation as I am referring to this type of app wrongly.
Maybe it is simply that the code is the documentation and I simply need to find where the manifest.json is parsed in the Chromium code. I thought it was worth asking here first though, and even if I end up being told to check the code then someone might give me a pointer there to get me started.
The "bookmark" apps you describe are officially called hosted apps. Here you have a description of both:
Apps
Contains installable web apps. An installable web app can be a normal website with a bit of extra metadata; this type of app is called a hosted app. Alternatively, an installable web app can bundle all its content into an archive that users download when they install the app; this is a packaged app. Both hosted and packaged apps have icons in Chrome's New Tab page, and most users shouldn't be able to tell the difference between them without looking at the address bar.
The documentation for app manifest only describes the options for packaged apps. As #wOxxOm notes in the comments, the only place currently describing a manifest for a hosted app seems to be the Getting Started tutorial.
I am working on my first extension and am trying to create a simple extension to inject a draggable div on a page. That works nicely, but I want to preserve the location of the div on the background page (I'm also trying out local storage, but want to understand why this isn't working).
I do not need a button so have not created a popup.html file, which, I believe, is entirely optional. It certainly has worked so far just injecting javascript files.
However, I now get the following error thrown when executing chrome.extension.getBackgroundPage():
Uncaught Error: chrome.extension.getBackgroundPage can only be used in extension processes. See the content scripts documentation for more details.
The content scripts documentation did not seem to identify anything wrong with my approach: http://code.google.com/chrome/extensions/content_scripts.html
Here is a redacted manifest I am using:
{
"name": "My helper",
"version": "1.0",
"description": "Tastes great",
"background_page": "background.html",
"content_scripts": [
{
"matches":["https://page.of.interest/*"],
"run_at":"document_idle",
"js":[ "jquery.js", "jquery-ui-1.8.17.custom.min.js", "my_content_script.js"],
"css": [ "my_content_script.css" ]
}
],
"permissions": [
"background"
]
}
So I am running this statement inside "my_content_script.js". Is this NOT considered part of the extension process? Can I only run this on a popup.html (or other possibly?) file?
If this is the case, then maybe it is easier to just use localstorage rather than trying to communicate through the dom with the extension process.
Hope I've been clear despite my ignorance about some of these concepts.
I don't think the docs explicitly say you can't use chrome.extension.getBackgroundPage() from a content_script but because the content_script has permissions more oriented with the page it is being run on it isn't allowed access. The docs do mention a few methods you can use however.
Unlike the other chrome.* APIs, parts of chrome.extension can be used by content scripts:
You will have to use message passing to communicate between the background_page and the content_script.
You have to use the chrome.cookies.get() in background.html, and then do the communication between your content script and background.html for exchanging cookie data.