Welcome guest, is this your first visit? Create Account now to join.
Page 2 of 2 FirstFirst 12
Results 11 to 18 of 18

This is a discussion on Where to start....... within the Plugins Development section, part of the Chrome Plugins category: Depends how you wanna store it. There's cookies which I don't recommend. localStorage which is pretty much the shiny new ...


  1. #11
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    Depends how you wanna store it.
    There's cookies which I don't recommend. localStorage which is pretty much the shiny new form of cookies. You can make a local database thing but I don't really know that API yet. Or lastly, you could send it to a server to store it, but that has privacy issues.
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

  2. #12
    couponmeup is offline Junior Member
    Join Date
    May 2009
    Posts
    9

    Default

    I'd like to build an array in the application if that's possible.
    I read that there is a way to have a "Resident" page that is loaded while the plug in exists, but I am not sure how to use it.

  3. #13
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

  4. #14
    couponmeup is offline Junior Member
    Join Date
    May 2009
    Posts
    9

    Default

    Thanks!
    OK, I added a background page.
    I am not sure how I communicate with it...
    I have some javascript running when a URL matches a given pattern from a JS file.

    I guess I need to store this globally, and call it from that javascript....
    How do I make it so that the array init only runs on first run?

  5. #15
    couponmeup is offline Junior Member
    Join Date
    May 2009
    Posts
    9

    Default

    I put this into my js file and it dies on this line.....
    var bg = chrome.extension.getBackgroundPage();

  6. #16
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    This explains how to communicate between background page and a content script.
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

  7. #17
    couponmeup is offline Junior Member
    Join Date
    May 2009
    Posts
    9

    Default

    Thanks for the pointer!
    OK, I copied this into my JS content script:
    chrome.extension.sendRequest({greeting: "hello"}, function(response) {
    console.log(response.farewell);
    });

    Then I copied this into my background.html
    <html>
    <script>

    chrome.tabs.getSelected(null, function(tab) {
    chrome.tabs.sendRequest(tab.id, {greeting: "hello"}, function(response) {
    console.log(response.farewell);
    });
    });

    chrome.extension.onRequest.addListener(
    function(request, sender, sendResponse) {
    console.log(sender.tab ?
    "from a content script:" + sender.tab.url :
    "from the extension");
    if (request.greeting == "hello") {
    sendResponse({farewell: "goodbye"});
    alert("blah");
    } else {
    sendResponse({}); // snub them.
    }
    });


    </script>
    </html>




    However, nothing appears in the console when it is fired.....
    Did I miss something?

  8. #18
    Waha's Avatar
    Waha is offline Senior Member
    Join Date
    Apr 2009
    Location
    Oregon
    Posts
    788

    Default

    The alert you have there is not going to work. They don't work from a background page. However, if you open the console on the page where the content script is executing (Ctrl+Shift+J) you should be able to see the logged message. If not, something is wrong with your page matching for that script in the manifest.
    ~ Projects ~
    Specialized: Carapass Auction Watcher, Kongregate Chat
    Libraries: bliplib
    Tools: manifest syntax highlighting & snippits
    ~ Happy to make extensions for pay too ;D ~
    Portfolio: Search and Share

Page 2 of 2 FirstFirst 12

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •