jquery - Using externally_connectable to Send Data from WWW to Chrome Extension -


i'm looking send data website localstorage of chrome extension.

i've tried below answer i'm looking for, appears not functioning @ on chrome 29 stable. advise why may be/tweaks?

it's not possible manage extension's localstorage website because of security rules.

but there method allows send message website extension.

consequently, may send data extension method , data on extension's background page whatever want (saving exension's localstorage).

it's explained in docs,

1. in manifest.json, let website allow sending message.

"externally_connectable": {   "matches": ["*://*.example.com/*"] } 

2. chrome.runtime.sendmessage available on website. (javascript)

chrome.runtime.sendmessage("your extension id here",                             {data: { anydatakey : "example"}}); 

3. in background.js create message listener external messages.

chrome.runtime.onmessageexternal.addlistener(   function(request, sender, sendresponse) {     if (request.data)       alert("hi, there message website");       var data = request.data;       // data on extension side, save extension's localstorage.   }); 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -