Google chrome notifciations icons without 'web_accessible_resources' - javascript

I'm currently working on a google chrome extension which needs to use notifications.
It's meant to extract an image from a site (got that part), upload it to imgur and then use it as the icon for the notification. My problem is:
All icons have to be listed under 'web_accessible_resources' before being used in a notification. However, my problem is that I create the icon while the extension is already running and I therefore cannot add it to the manifest.
Is there any workaround for this?

Try a data URI. This is extra text to reach the 30-character minimum.

Related

Question about messaging passing in Google Chrome Extension

In my content script, it's looking for certain keywords in the webpages title. If they are found, I want it to display a notification, using Google's notification API. However, you can't use google's notification API in the content.js - apparently it needs to be in a background file. Any idea how I do this?

Download image, then save locally and access: Chrome extension

I am working on a chrome extension which acts as the new tab page for a user. A number of users have asked for the ability to use their own, locally saved pictures as a background image. However, I have not been able to find a way to do this.
I am aware that there are many questions on StackOverflow with the same title as mine, but none address my specific needs:
I need to download an image from a URL (i.e. a temporary Dropbox or Google Drive URL), or use an image from an HTML5 filepicker, as in this demo.
The image then needs to be saved locally, preferably to the extension directory, and be accessed by the extension every time it loads
I do not have access to PHP or to a server on which I could call a script or host images
The other answers suggest I use the Chrome FileSystem API. However, I understand that this API is only available to Chrome apps or on Chrome OS, not to extensions.
I also found an answer that mentions the file permission in the extension's manifest file.
"permissions": [
"file://*/*"
]
I would not be against using such a permission, even though "The user has to manually approve this permission by visiting chrome://extensions/ and put a tick at the "Allow access to file URLs" checkbox," as stated on this StackOverflow answer.
However, I would not know where to start with implementing this. Your help is very much appreciated!
** I am using jQuery in my extension, so that is an option, although I would prefer to use pure JS.
*** The extension is CleanStart for Chrome, in case that is important.
Just an idea:
Maybe I could use chrome.storage to save a hex string representing the image, and then retrieve that string and convert it back to an image, as in this StackOverflow answer.

System tray icon for Chrome extension

My manifest includes a nice icon and my background.js page triggers the extension's main functionality.
Is there some easy way to get the exact same functionality within the notification tray? In other words, is there any way to put an icon in the task bar (like google does with the hangouts extension), and trigger a single event when it is clicked.
Here is the code I use for the action button in the browser itself:
chrome.browserAction.onClicked.addListener(function(tab)
{
mainFunction();
});
I'd imagine there is a simple addition to the manifest along with a simple line like the above, that would achieve my desired result.
Chrome extensions don't have access to the system tray, and there is no API for that.
Hangouts is specifically whitelisted in the Chromium source code to get some special privileges.

Setting src of an image to a Chrome's extension stored file?

This is an example that shows what's my problem.
I'm writing a chrome extension that should replace google's logo in google main page (google.com). So I create a content-script that uses this javascript+jQuery code to do it (Please forgo google doodles!):
$("#hplogo").attr("src","the_address");
This content-script matches with https://*.google.com/ which contains google's main page.
Okay. If I put in the_address an image address which is uploaded on the internet, the extension works properly and gives me ideal result.
But since I don't want my extension to make loading time long for slow connections, I'm going to set the image's src to a file from hard disk.
So I put the image file to extension's folder then I tried the file name (eg : image1.gif) as the_address, but this time, the chrome doesn't load the image.
What have I to do? Thanks, gúys.
For obvious reasons the image won't load, I assume it is still using the webpage's domain. You may need to use chrome.extension.getURL, which allows you to link resources from an extension directory.

Download multiple images without asking in Chrome extension

I am currently creating a Chrome extension (which uses javascripts mainly) that allows users to scrape the images on a webpage and download them. I have finished the link scraping part, and the code will return an array like:
["http://example.com/image1.jpg","http://example.com/image2.jpg"]
But how do I download all of the links in ONE CLICK? I tried listing all photos on a new tab and let the users to Ctrl+S save the page. But this greatly affects the UI and I do not like it. I do not host webpage so server side script may not be working.. Any other solutions?
As far as I know, Chrome extensions technically can't save files to disk like Firefox.
The only way to do this is using NPAPI
Unfortunately, extensions using npapi will most likely not be accepted by the Web Store due to security problems. Of course it'll be okay if you use it for yourself or host the extension on your website.
You can install and examize the code of the following extensions, maybe you can even use the provided npapi too:
Screen Capture (by Google) https://chrome.google.com/webstore/detail/cpngackimfmofbokmjmljamhdncknpmg
Chrome Toolbox (by Google) https://chrome.google.com/webstore/detail/fjccknnhdnkbanjilpjddjhmkghmachn
Awesome Screenshot: Capture & Annotate https://chrome.google.com/webstore/detail/alelhddbbhepgpmgidjdcjakblofbmce
Download Asisstant (by Google) - got killed I guess.

Categories