[crx] LocalStorage Popup / Background Reload?

853 views
Skip to first unread message

bryanosaurus

unread,
May 11, 2010, 5:01:08 PM5/11/10
to Chromium-extensions
I have an extension where the user inputs say, a name, into a dialog
box in the popup html. This name is stored with localstorage.
Now, what this extension is supposed to do is alter certain links to
contain the name they put into storage. (ex google.com gets changed to
google.com/name)
This is done obviously by a content script that is communicating via
some json in the background/content pages.

The extension works exactly as intended, except when the data is input
into popup.html and saved, the browser must be closed and reopened
before the changes take effect on the pages.
I tried adding refresh scripts to the background and popup pages
(which I later read won't work). Is there anyway around this issue, or
must I FORCE the user to restart the browser before the plugin works?

Any help/insight/ideas would be greatly appreciated!

--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.

Derek 囧

unread,
May 11, 2010, 6:25:49 PM5/11/10
to Chromium-extensions
// POPUP PAGE
function save(){
localStorage["WHATEVER"] = input.value;
}

// BACKGROUND PAGE

//onload
var txt=localStorage["WHATEVER"]
//check
cc();
function cc(){
if(localStorage["WHATEVER"]!=txt){
txt=localStorage["WHATEVER"]
// If you really want to communicate with the content script, use
this:
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(tab.id, {greeting: txt}, function(response)
{});
});
}
setTimeout('cc()',500)
}

// CONTENT SCRIPT
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
location.href=request.greeting;
});
Reply all
Reply to author
Forward
0 new messages