From 8ddfa5438135ffb0c8310e0efee1051143be9af4 Mon Sep 17 00:00:00 2001 From: daniloroz Date: Thu, 21 Apr 2022 17:44:48 -0400 Subject: [PATCH] Add Action to clear cookies of the current tab. (issue 81) --- src/background.js | 13 +++++++++++++ src/content.js | 1 + 2 files changed, 14 insertions(+) diff --git a/src/background.js b/src/background.js index f3f3e74..1c54ffe 100644 --- a/src/background.js +++ b/src/background.js @@ -70,6 +70,7 @@ const clearActions = () => { {title:"Clear all browsing data", desc:"Clear all of your browsing data", type:"action", action:"remove-all", emoji:true, emojiChar:"๐Ÿงน", keycheck:false, keys:['โŒ˜','D']}, {title:"Clear browsing history", desc:"Clear all of your browsing history", type:"action", action:"remove-history", emoji:true, emojiChar:"๐Ÿ—‚", keycheck:false, keys:['โŒ˜','D']}, {title:"Clear cookies", desc:"Clear all cookies", type:"action", action:"remove-cookies", emoji:true, emojiChar:"๐Ÿช", keycheck:false, keys:['โŒ˜','D']}, + {title:"Clear current site cookies", desc:"Clear cookies for the current tab", type:"action", action:"remove-current-cookies", emoji:true, emojiChar:"๐Ÿช", keycheck:false, keys:['โŒ˜','D']}, {title:"Clear cache", desc:"Clear the cache", type:"action", action:"remove-cache", emoji:true, emojiChar:"๐Ÿ—„", keycheck:false, keys:['โŒ˜','D']}, {title:"Clear local storage", desc:"Clear the local storage", type:"action", action:"remove-local-storage", emoji:true, emojiChar:"๐Ÿ“ฆ", keycheck:false, keys:['โŒ˜','D']}, {title:"Clear passwords", desc:"Clear all saved passwords", type:"action", action:"remove-passwords", emoji:true, emojiChar:"๐Ÿ”‘", keycheck:false, keys:['โŒ˜','D']}, @@ -328,6 +329,15 @@ const clearBrowsingData = () => { const clearCookies = () =>{ chrome.browsingData.removeCookies({"since": 0}); } +const clearCurrentCookie = () => { + getCurrentTab().then((response) => { + chrome.browsingData.remove({ + "origins": [response.url] + }, { + "cookies": true + }); + }); +} const clearCache = () => { chrome.browsingData.removeCache({"since": 0}); } @@ -402,6 +412,9 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => { case "remove-cookies": clearCookies(); break; + case "remove-current-cookies": + clearCurrentCookie(); + break; case "remove-cache": clearCache(); break; diff --git a/src/content.js b/src/content.js index bca5555..ecd5c20 100644 --- a/src/content.js +++ b/src/content.js @@ -357,6 +357,7 @@ $(document).ready(() => { case "remove-all": case "remove-history": case "remove-cookies": + case "remove-current-cookies": case "remove-cache": case "remove-local-storage": case "remove-passwords":