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 9152187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:58:53+00:00 2026-06-17T11:58:53+00:00

I am currently converting one of my userscripts to a chrome extension. The only

  • 0

I am currently converting one of my userscripts to a chrome extension. The only thing I am still stuck with is successfully storing the localStorage values in variables in my content script. I will give one example here, the other ones are similar but with other names.

var REMOVE_WARNINGS;

chrome.extension.sendRequest({method: "REMOVE_WARNINGS"}, function(response) {
console.log(response.status);
REMOVE_WARNINGS = response.status == "true";
});

As you can see, I query the localStorage of my extension for the value that was assigned to “REMOVE_WARNINGS”. I do that because further on in the content script, this variable gets checked to see whether it has to perform certain actions or not. The original value gets assigned in the localStorage through the options page by a HTML option, either true or false, which happens without a problem. The value “true” (or “false”) gets successfully returned to the content script’s method and printed in the console, because I have checked it. What DOESN’T work is assigning the value to the global variable REMOVE_WARNINGS in my content script.

I have tried a few options, including REMOVE_WARNINGS = response.status;, REMOVE_WARNINGS = response.status == "true"; and I have also tried to remove the console output line thinking that it might print destructively. None of these options seems to successfully store the boolean value “true” or “false” in the global variable, because the script does not perform the actions it should do.

Does anyone see what I’m doing wrong here? I’m completely lost at this point, especially since clearly reading the value is no problem. It’s storing it in a global variable of the content script, that is the problem.

Cheers
Kenneth

  • 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-06-17T11:58:54+00:00Added an answer on June 17, 2026 at 11:58 am

    Please correct me if I’m wrong but I think you’re trying to do something like:

    var REMOVE_WARNINGS;
    
    chrome.extension.sendRequest({method: "REMOVE_WARNINGS"}, function(response) {
        console.log(response.status);
        REMOVE_WARNINGS = response.status == "true";
    });
    console.log(REMOVE_WARNINGS); //this console.log will fail? right?
    

    Try to modify your code like this:

    chrome.extension.sendRequest({method: "REMOVE_WARNINGS"}, function(response) {
        console.log(response.status);
        REMOVE_WARNINGS = response.status == "true";
        doSomething();
    });
    
    function doSomething() {
        console.log(REMOVE_WARNINGS); //this one should work
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'am currently converting a svn repository into a git one. As I proceed manually,
I'm currently converting a test class which extended the Spring class AbstractTransactionalSpringContextTests to Spring
I'm currently converting some legacy code to create PDF files using iTextSharp. We're creating
Currently working with converting SQLException error messages into messages that are more useful for
I am currently working on converting a ColdFusion website, using Fusebox framework, to PHP.
I'm currently having an issue wrapping my brain around the notion of converting my
I'm currently building a converter in C#. My program is converting from/to Decimal, Binary
I have an application that I'm converting to Symfony/Doctrine. It currently stores a serialized
I have an iPhone application that I am currently converting to a universal binary
I am currently working on converting an application from access to C# and have

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.