I would like to pass a saved varliable from the content script to the popup page, so I would be able to simply output it.
For example, if my content script has the following code:
var x = 'abc';
I would like the popup title to be this varliable.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
Couple ways to do this, I used the first one in my extension:
localStorage. UsesendRequest({})to pass a message with your variable to the background page, which will then save the variable tolocalStorage. Once that’s done, your popup can access the variable likelocalStorage["x"]. (It has to go through the background page because at this time, content scripts cannot accesslocalStorage)Plain requests. Pray that the popup is open, and try sending it a message from the content script with the variable in it. Note that this is not a good solution simply because the popup might not be open when you try to send it the variable.
Code Example for #1: