From cf0070ac5a78d8042fa74d407fb9cb65352e2066 Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Tue, 5 Nov 2024 02:58:33 -0500 Subject: Initial commit --- extension/background.js | 23 +++++++++++++++++++++++ extension/main.css | 0 extension/manifest.dhall | 30 ++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 extension/background.js create mode 100644 extension/main.css create mode 100644 extension/manifest.dhall (limited to 'extension') diff --git a/extension/background.js b/extension/background.js new file mode 100644 index 0000000..a0f4c91 --- /dev/null +++ b/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); diff --git a/extension/main.css b/extension/main.css new file mode 100644 index 0000000..e69de29 diff --git a/extension/manifest.dhall b/extension/manifest.dhall new file mode 100644 index 0000000..cf9e7a1 --- /dev/null +++ b/extension/manifest.dhall @@ -0,0 +1,30 @@ +{ manifest_version = 2 +, name = "computerspotting" +, version = "1.0" +, description = "spot the computer" +, icons = + [ { mapKey = "48", mapValue = "assets/mrgreen.png" } + ] +, web_accessible_resources = + [ "mrgreen.png" + , "mrblue.png" + ] +, permissions = + [ "webRequest" + , "webRequestBlocking" + , "tabs" + , "cookies" + , "*://*.twitch.tv/*" + , "*://api.colonq.computer/*" + ] +, background = + { scripts = ["background.js"] + } +, content_scripts = + [ { matches = ["*://*.twitch.tv/*"] + , js = ["config.js", "main.js"] + , css = ["main.css"] + , run_at = "document_end" + } + ] +} \ No newline at end of file -- cgit v1.2.3