diff --git a/background.js b/background.js index e69de29..9fa68db 100644 --- a/background.js +++ b/background.js @@ -0,0 +1,4 @@ +chrome.runtime.onInstalled.addListener(() => { + console.log("Reject Cookies extension installed."); + }); + \ No newline at end of file diff --git a/content.js b/content.js index a3387fe..5510aaa 100644 --- a/content.js +++ b/content.js @@ -1,17 +1,26 @@ -const selectors = [ - 'button[aria-label="reject"]', - 'button[data-testid="reject"]', - 'button[class*="reject"]', - ]; +chrome.storage.sync.get('selectors', (data) => { + const selectors = data.selectors || [ + 'button[aria-label="reject"]', + 'button[data-testid="reject"]', + 'button[class*="reject"]' + ]; - function clickButton(selector) { - const button = document.querySelector(selector); - if (button) { - button.click(); + function clickButton(selector) { + try { + const button = document.querySelector(selector); + if (button) { + console.log(`Clicked button with selector: ${selector}`); + button.click(); + // Notify user + new Notification("Reject Cookies", { body: `Rejected cookies with selector: ${selector}` }); + } + } catch (error) { + console.error(`Error clicking button with selector: ${selector}`, error); + } } - } - selectors.forEach(selector => { - clickButton(selector); + selectors.forEach(selector => { + clickButton(selector); + }); }); \ No newline at end of file diff --git a/images/icon128.png b/images/icon128.png new file mode 100644 index 0000000..df64851 Binary files /dev/null and b/images/icon128.png differ diff --git a/images/icon16.png b/images/icon16.png new file mode 100644 index 0000000..b6568e5 Binary files /dev/null and b/images/icon16.png differ diff --git a/images/icon48.png b/images/icon48.png new file mode 100644 index 0000000..c94ed10 Binary files /dev/null and b/images/icon48.png differ diff --git a/manifest.json b/manifest.json index 456f0de..fe3c5ce 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "Reject Cookies", "version": "1.0", "description": "Automatically reject all cookie popups.", - "permissions": ["activeTab", "scripting"], + "permissions": ["activeTab", "storage", "scripting"], "background": { "service_worker": "background.js" }, @@ -13,6 +13,14 @@ "js": ["content.js"], "run_at": "document_end" } - ] + ], + "action": { + "default_popup": "popup.html", + "default_icon": { + "16": "images/icon16.png", + "48": "images/icon48.png", + "128": "images/icon128.png" + } + } } \ No newline at end of file diff --git a/popup.html b/popup.html new file mode 100644 index 0000000..77e727f --- /dev/null +++ b/popup.html @@ -0,0 +1,78 @@ + + +
+
+ Enter CSS selectors for cookie rejection buttons. One per line.
+
For example: button[aria-label="reject"]
+