Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7593859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:16:30+00:00 2026-05-30T21:16:30+00:00

I’m making a content script extension for Google Chrome, it adds functionality to a

  • 0

I’m making a content script extension for Google Chrome, it adds functionality to a website’s page. I want to add a couple of options, not big deal really, I’d just need two strings (none of which are sensitive user data).

From this answer, I assume I need a background page, which I’d rather not add to my extension – I don’t want it to gain unnecessary weight.

Do I really need a background page, or I could have an options page without it (and which storage could I use)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T21:16:32+00:00Added an answer on May 30, 2026 at 9:16 pm

    UPDATE
    As of Chrome 20 you can now use the Storage api…..
    http://code.google.com/chrome/extensions/storage.html

    Old way
    What I do is create an iframe that points to a page in my extension that has a script that gets the settings I need from local storage and then sends that to its parent in a message which the content script then gets…..well that was a crap explanation, the code says it better ;)…….

    Content Script

    // create the iframe for our page that sends the settings
    var el = document.createElement("iframe");
    el.setAttribute('src', chrome.extension.getURL("gimmeSettings.html"));
    el.style.visibility="hidden";
    document.body.appendChild(el);
    
    // create the listner that listens for a message from our page that sends the settings
    window.addEventListener("message", receiveSettings, false);
    
    // function that gets called when we recieve a message from the page that sends the settings  
    function receiveSettings(event) {
            //check to make sure the message came from our page
            if (event.origin !== "chrome-extension://"+chrome.i18n.getMessage("@@extension_id")) return;
    
            //message came from our extension, do stuff with it  
            console.debug(event.data);
    
            // clean up
            window.removeEventListener("message", receiveSettings, false);
            el.parentNode.removeChild(el);
    }
    

    gimmeSettings.html’s JS

    // post the message with our settings
    parent.postMessage( localStorage.getItem("testing"), "*" );
    

    Options.html’s JS

    localStorage.setItem("testing","bleh");
    

    Manifest

    {
        "name": "Getting at an extensions local storage from a content script",
        "description" : "Getting at an extensions local storage from a content script.  Be aware that other pages/extensions can use this to get at your settings, but not change them...so dont include sensitvie data.",
        "content_scripts": [
            {
                "matches": ["<all_urls>"],
                "js" : ["myscript.js"],
                "run_at":"document_idle"
            }
        ],
        "permissions": [
            "tabs", "<all_urls>"
        ],
        "manifest_version": 2,
        "web_accessible_resources": [
        "gimmeSettings.html"
      ],
      "options_page": "options.html",
        "version":"1.0"
    }
    

    Some things to note….
    Other pages and extensions can easily use this to also get the settings from your extension, so dont use any sensitive data with this method.
    From the best I can tell there is no way for them to alter your settings through that page tho, if anyone knows different please explain.
    Im using manifest version 2 and have set the page gimmeSettings to be accessible. If you dont know the differences manifest version 2 add you really should read up on it…. http://code.google.com/chrome/extensions/trunk/manifestVersion.html

    And if you want a working example then go here…..
    http://forum.valorsolo.com/viewtopic.php?f=36&t=375

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I used javascript for loading a picture on my website depending on which small
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.