diff options
| author | LLLL Colonq <llll@colonq> | 2024-03-19 03:37:33 -0400 |
|---|---|---|
| committer | LLLL Colonq <llll@colonq> | 2024-03-19 03:37:33 -0400 |
| commit | fbabf1d29a8a97d57d9609666c81701fe12979e1 (patch) | |
| tree | c9e7f4c0185dedf084558aeeea69140a326a19ef /fig-frontend-client/extension/background.js | |
| parent | 7aa60d33eff21ccdaa31ccd5dd64196990bb3dea (diff) | |
Update
Diffstat (limited to 'fig-frontend-client/extension/background.js')
| -rw-r--r-- | fig-frontend-client/extension/background.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/fig-frontend-client/extension/background.js b/fig-frontend-client/extension/background.js new file mode 100644 index 0000000..a0f4c91 --- /dev/null +++ b/fig-frontend-client/extension/background.js @@ -0,0 +1,23 @@ +/* Retrieve any previously set cookie and send to content script */ + +function getActiveTab() { + return browser.tabs.query({active: true, currentWindow: true}); +} + +function cookieUpdate() { + getActiveTab().then((tabs) => { + // get any previously set cookie for the current tab + let gettingCookies = browser.cookies.get({ + url: tabs[0].url, + name: "name" + }); + gettingCookies.then((cookie) => { + browser.tabs.sendMessage(tabs[0].id, cookie.value); + }); + }); +} + +// update when the tab is updated +browser.tabs.onUpdated.addListener(cookieUpdate); +// update when the tab is activated +browser.tabs.onActivated.addListener(cookieUpdate); |
