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

  • Home
  • SEARCH
  • 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 6847805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:47:24+00:00 2026-05-27T00:47:24+00:00

I have a Chrome Extension I’m trying to add features with an enable/disable option.

  • 0

I have a Chrome Extension I’m trying to add features with an enable/disable option.

I have checkboxes in popup.html that onclick, write the value of the boxes to localStorage. Then in my content script, I send a request for the value.

I used to only have 1 request, and it worked fine. Then I tried to add another, and no matter what I try, it doesn’t work, even if I comment out the other request. Here’s the code in my content script:

autopoke = 'default';
secondbutton = 'default';

chrome.extension.sendRequest({localstorage: "autopoke"}, function(response)
{ 
if (response.autopoke == "true")
        {
        autopoke = true;
        }
})

chrome.extension.sendRequest({localstorage: "secondbutton"}, function(response)
{ 
console.log(response) //for debugging
if (response.secondbutton == "true")
        {
        secondbutton = true;
        }
})

No matter if the “secondbutton” localStorage variable is true or not, the output of the second request is blank.
The output to Chrome’s Console is also a blank object. I tried moving that line to the first request, and it outputted an object, in which was “autopoke = false” somewhere.

To make sure the localStorage value is set, I added this to popup.html:

alert(localStorage.secondbutton);

And when I click on the popup, an alert comes up saying true. I really can’t figure this out, I even tried setTimeout() to wait a few seconds, but the results are the same: a blank output for the localStorage “secondbutton”.

background.html:

<html>

<script type='text/javascript'>
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {

if (request.localstorage == "autopoke") {
sendResponse({autopoke: localStorage.autopoke});
}
else {
sendResponse({}); // snub them.
}    
});
</script>

</html>

popup.html:

<html>
<head>

<style type='text/css'>
    body
    {
        font-size:10pt;
        width:220px;
        font-family: "Verdana";
        font-weight: bold;
        text-shadow: 2px 2px 2px green;
    }

</style>

<script type='text/javascript'>
    function update()
    {
    localStorage.autopoke = document.myform.check.checked;
    localStorage.secondbutton = document.myform.secondbutton.checked;
    }
</script>
</head>
<body>
    <form name='myform'>
    <table border="0">
        <tr>    
            <td>
                <label for='check'>Autopoke:</label> 
            </td>   
            <td>    
                <input type='checkbox' id='check' onclick='update()'/>
            </td>
        </tr>

        <tr>
            <td>
                <label for='secondbutton'>Additional Poke Button:</label> 
            </td> 
            <td>
                <input type='checkbox' id='secondbutton' onclick='update()'/>
            </td>
        </tr>

    </table>
    </form>
    <script type='text/javascript'>
    if( localStorage.autopoke == "true")
    {
      document.myform.check.checked=true;
    }
    if ( localStorage.secondbutton == "true" )
    {
      document.myform.secondbutton.checked=true;
    }
    </script>
</body>
</html>
  • 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-27T00:47:24+00:00Added an answer on May 27, 2026 at 12:47 am

    Okay, let’s see what’s going on here. You’re first sending a request with localstorage = "autopoke". The if statement in the request handler holds, and sends back the localStorage.autopoke value. Now, why doesn’t it respond anything when you send localstorage = "secondbutton"? Well, there’s no place in your code that value is returned. Try the code below, it should do the trick.

    chrome.extension.onRequest.addListener(function(request, sender, sendResponse) 
    {
        if (request.localstorage == "autopoke")
        {
            sendResponse({autopoke: localStorage.autopoke});
        }
        else if (request.localstorage == "secondbutton")
        {
            sendResponse({secondbutton: localStorage.secondbutton});
        }
        else
        {
            sendResponse({}); // snub them.
         }    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this chrome extension that shows some content in the popup.html. As the
Suppose we have Chrome extension, that uses background page, popup page, maybe some other
I'm trying to build a Chrome extension that will have a heavy use of
I have a Chrome extension with a browser action that is trying to imitate
I'm trying to build a Chrome extension that will automatically disable the webkit-text-size-adjust CSS
I have chrome extension in that I am trying to use GWT RPC. Cant
Happy new year :) I have a Chrome extension which is a popup that
I have this Chrome extension that modifies the header of requests before sending them.
I have a Chrome Extension that is using the experimental sidebar API. It works
I want to have a chrome extension that adds a little bar to the

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.