In my Chrome Extension, I am using webkitNotifications.createNotification to alert users. It's a great tool!! In the sample code given, the first parameter is optional and specifies an an icon and the Google instructions claim that it can be a local reference. When I use a local file, I get a broken image link. This even occurs when I use the sample for Notification Demo located here - http://code.google.com/chrome/extensions/samples.html#f799e26ceef2367cf836f24bcb47df4398b0df58
Does anyone else have this issue?
The icon is listed in my manifest file.
I can get around this by using a complete web reference, but I like to use this tool for error notifications and sometimes the error is caused by an interruption of internet access.
I am using chrome version 18.0.1025.151 m.
Thanks!
The problem with their sample is they have included "manifest_version": 2 in their manifest but not added a "web_accessible_resources" listing what resources should be available to pages.
You can read more about manifest_version 2 and what changes it introduces here....
http://code.google.com/chrome/extensions/manifestVersion.html
...and about web_accessible_resources here....
http://code.google.com/chrome/extensions/manifest.html#web_accessible_resources
To fix the problem in the sample, you can either remove the manifest version 2 bit (even the docs say this wont be required for a while yet). Or you can add the following to the manifest....
"web_accessible_resources": [
"48.png"
]
"Web Accessible" means the resources is being accessed from your server so you must make sure to include the path to the resources in your javascript and in the manifest,json.
Related
I wanted to test onUpdateAvailable event in chrome extension.
https://developer.chrome.com/extensions/runtime#method-requestUpdateCheck
I have tried updating the maniefest version but it didn't work.
Can someone help?
You can specify "update_url" in your manifest file which is mapped to your local server and change it when you need.
The URL should be a link to an XML document, you can check example here.
I tried to inject jQuery to content page to make easy access to DOM elements.
The code was something like below
chrome.tabs.executeScript(tabId, { file: "jquery.min.js"} ,function(){
chrome.tabs.executeScript(tabId, { file: myOwnScript.js});}
);
It was all fine on Windows, but on Ubuntu, in content page window, I always get console error message saying
"Not allowed to load local resource: file:///****/jquery.min.map"
I noted it was talking about *.map but not *.js
There are some more mysteies:
1. There is no error message on myOwnScript.js
2. My extension works well even though this message keeps showing at each page load.
I made plenty searches on Google but didn't find similar case.
My questions is,
1. What is the reason of such error?
2. Should I take it as a serious error?
My enviroment is as below
OS : Ubuntu 14.04, with LXDE desktop
Chrome : 34.0.1847.132
(Didn't try other configurations because I am not that good at customizing Linux :)
Previous versions of Jquery have a comment pointing to the map file (so that a bug in jquery.min.js can be translated to a bug in the readable jquery.js). You can safely delete this comment, or upgrade to a more recent version of Jquery, which has removed this comment (for exactly this reason). See also this answer.
Has anyone successfully implemented drag and drop with files from desktop to the app?
I've tried just putting this drag 'n' drop example into the index file but I just get this error:
Can't open same-window link to "file:///C:/Users....whatever"; try target="_blank".
Please share your stories, what you've tried and if you have succeed :)
Some resources to help you:
New Chrome Packaged Apps codelab that we've been working on covers drag-and-drop in both AngularJS and pure JavaScript.
AngularJS drag-and-drop: https://github.com/GoogleChrome/chrome-app-codelab/tree/master/lab5_data/angularjs/2_drop_files
JavaScript drag-and-drop: https://github.com/GoogleChrome/chrome-app-codelab/tree/master/lab5_data/javascript/2_drop_files
There's an early version of docs too for AngularJS drag-and-drop for Chrome at developer.chrome.com/trunk/apps/app_codelab5_data.html#handle_drag_and_dropped_files_and_urls
We're working on the docs to cover both samples though.
I have done this a while ago and it worked.
The problem you've got is that you are creating a file url, then trying to navigate to the url. The navigation is failing, not the read. It's failing due to CSP, and you probably won't be able to override that with a different CSP due to security restrictions we've placed on allowable CSPs.
But, you should be able to just read the file and use the content. You need to change that sample code to use ReadAsText or ReadAsArrayBuffer instead of readAsDataURL. Look here for more details.
Please let us know how you get on!
Just listening for drop won't work. You will have to prevent the default functionality of dragover.
document.body.addEventListener('dragover', function(e) {
e.preventDefault();
}
document.body.addEventListener('drop', function(e) {
alert('it works!')
}
I'm trying to make an app for Spotify, but I can't get the first step to work. I have made a folder named 'Spotify' in 'My Documents' (I use Windows 7 64 Bit), and made a folder inside it named 'test'. In 'test' I put a file 'index.html' to test if I can open it in Spotify, but I can't. I have a developer account, so that can't be a problem. When I type 'spotify:app:test' in the search bar, I get something like this:
(Note, in the screenshot it says spotify:app:tutorial, but I get the exact same result as displayed when I type spotify:app:test, saying failed to load application)
Also, I use Spotify version 0.8.7.111.gaf8d06ed-245
Spotify cannot load an application unless it has a valid manifest file. The manifest documentation can be found here.
Alternatively, see the Spotify Apps Tutorial app for a working example of a valid manifest. Note that you at least need an identifier, version and name for a manifest to be considered valid.
I tried following Google's example: https://developer.chrome.com/extensions/options.html
I immediately encountered the problem of the button and body trying to execute functions, so I attached listeners instead. Then, it's telling me that the options page isn't allowed to execute JS.
Either I didn't properly understand how to do that, or Chrome's documentation is entirely wrong.
How do you use JS in there? Or: can you point me in the direction of a proper tutorial.
Check out this answer: Chrome tutorials - options page
"manifest_version": 2 forbids embedded scripts. Move all of the JavaScript to options.js and load it that way."
You can't use inline JS with manifest v2.0 that is required for new extensions. That was possible with manifest v1 but not now. You have to reference script file to page. This issue if present on all extension pages.
<script type="text/javascript">JS CODE</script>
Is not allowed anymore. Use this instead.
<script type="text/javascript" src="FILENAME.js"></script>
Take a look at google code docs - manifest