extension refresh on site load any way to store the variable or anything else

39 views
Skip to first unread message

Vivek Sagar

unread,
Apr 10, 2023, 2:25:01 PM4/10/23
to Chromium Extensions
i am creating an extension in which, from the popup, i will let user choose the color and change it on the active site but i m have a issue i used tabs.message it worked but the color user picked get remove when the site loaded again is there any good way to connect the event js with content script or using service worker ?

Patrick Kettner

unread,
Apr 10, 2023, 2:28:14 PM4/10/23
to Vivek Sagar, Chromium Extensions
 Like you use chrome.storage to save the selected color when it is changed and onContentLoaded in a content script to load whatever  the saved value is in?

On Mon, Apr 10, 2023 at 2:25 PM Vivek Sagar <vivek...@gmail.com> wrote:
i am creating an extension in which, from the popup, i will let user choose the color and change it on the active site but i m have a issue i used tabs.message it worked but the color user picked get remove when the site loaded again is there any good way to connect the event js with content script or using service worker ?

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/ded14a5f-d29f-41ad-b873-ae121112e111n%40chromium.org.

Vivek Sagar

unread,
Apr 11, 2023, 12:34:48 AM4/11/23
to Patrick Kettner, Chromium Extensions
Yes Not Exactly let me explain properly
I have an popup html linked with event.js file using that i will let user choose the color then change the background of the website on which the extension is used.

But the issue is how can i connect the event.js with content.js so that the color code info get transferred to content js and the background will change. 

I jused the message api to create communication and it worked  but the thing is when that page reload the contents script get reset i want something that can store that color code value when user choose and also work when the website reload

Patrick Kettner

unread,
Apr 11, 2023, 3:08:28 PM4/11/23
to Vivek Sagar, Chromium Extensions
I apologize, I meant "Can you use", rather than "like you use". 

As in, could you check if a value is set onLoad, and then use that, otherwise request the user pick a color? You can access chrome.storage from any context, so you can add an event listener for the storage value
Reply all
Reply to author
Forward
0 new messages