Created
September 16, 2022 21:39
-
-
Save dvalter/fa123bcaca278a8bb6de575d2c22c97e to your computer and use it in GitHub Desktop.
I don't care about cookies diff between chrome and firefox releases as of v3.4.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/data/context-menu.js b/src/data/context-menu.js | |
index 0d40ee0..610c325 100644 | |
--- a/src/data/context-menu.js | |
+++ b/src/data/context-menu.js | |
@@ -2,7 +2,13 @@ | |
var cached_rules = {}, | |
whitelisted_domains = {}, | |
- tab_list = {}; | |
+ cookie_warning_dismissed_domains = {}, | |
+ tab_list = {}, | |
+ xml_tabs = {}; | |
+ | |
+ | |
+// FF only: debugging mode | |
+var debug_mode = false; | |
// Common functions | |
@@ -25,6 +31,31 @@ function getHostname(url, cleanup) | |
} | |
+// Badges | |
+ | |
+function setBadge(tabId, text) { | |
+ if (!chrome.browserAction.setBadgeText) | |
+ return; | |
+ | |
+ chrome.browserAction.setBadgeText({text: text || '', tabId: tabId}); | |
+ | |
+ if (chrome.browserAction.setBadgeBackgroundColor) | |
+ chrome.browserAction.setBadgeBackgroundColor({color: '#646464', tabId: tabId}); | |
+} | |
+ | |
+function setSuccessBadge(tabId) { | |
+ setBadge(tabId, '✅'); | |
+} | |
+ | |
+function setDisabledBadge(tabId) { | |
+ setBadge(tabId, '⛔'); | |
+} | |
+ | |
+function resetBadge(tabId) { | |
+ setBadge(tabId); | |
+} | |
+ | |
+ | |
// Whitelisting | |
function updateWhitelist() | |
@@ -107,6 +138,11 @@ function getPreparedTab(tab) | |
tab.host_levels.push(parts.slice(-1*i).join('.')); | |
tab.whitelisted = isWhitelisted(tab); | |
+ | |
+ if (tab.whitelisted) | |
+ setDisabledBadge(tab.id || tab.tabId); | |
+ else if (cookie_warning_dismissed_domains[tab.hostname]) | |
+ setSuccessBadge(tab.id || tab.tabId); | |
} | |
} | |
@@ -115,7 +151,9 @@ function getPreparedTab(tab) | |
function onCreatedListener(tab) | |
{ | |
- tab_list[tab.id] = getPreparedTab(tab); | |
+ resetBadge(tab.id); | |
+ | |
+ tab_list[tab.id] = getPreparedTab(tab); | |
} | |
function onUpdatedListener(tabId, changeInfo, tab) { | |
@@ -154,6 +192,22 @@ chrome.runtime.onInstalled.addListener(function(d){ | |
if (d.reason == "update" && chrome.runtime.getManifest().version > d.previousVersion) | |
recreateTabList(); | |
+ | |
+ | |
+ // FF only: debugging mode | |
+ | |
+ if (d.temporary && d.temporary === true) | |
+ { | |
+ recreateTabList(); | |
+ debug_mode = true; | |
+ | |
+ chrome.notifications.create('debug', { | |
+ type: "basic", | |
+ title: "IDCAC debugging mode", | |
+ message: "You have installed IDCAC in debugging mode. You will be notified when custom rules get applied to websites.", | |
+ iconUrl: "icons/48.png" | |
+ }); | |
+ } | |
}); | |
@@ -200,6 +254,17 @@ function blockUrlCallback(d) | |
if (group_filters[i].e[exception] == tab_list[d.tabId].host_levels[level]) | |
return {cancel:false}; | |
+ if (debug_mode) { | |
+ chrome.notifications.create('request_blocked', { | |
+ type: "basic", | |
+ title: "IDCAC debugging mode", | |
+ message: "Block pattern found: " + group_filters[i].r, | |
+ iconUrl: "icons/48.png" | |
+ }); | |
+ } | |
+ | |
+ setSuccessBadge(d.tabId); | |
+ | |
return {cancel:true}; | |
} | |
} | |
@@ -223,6 +288,17 @@ function blockUrlCallback(d) | |
if (group_filters[i].e[exception] == tab_list[d.tabId].host_levels[level]) | |
return {cancel:false}; | |
+ if (debug_mode) { | |
+ chrome.notifications.create('request_blocked', { | |
+ type: "basic", | |
+ title: "IDCAC debugging mode", | |
+ message: "Block pattern found: " + group_filters[i].r, | |
+ iconUrl: "icons/48.png" | |
+ }); | |
+ } | |
+ | |
+ setSuccessBadge(d.tabId); | |
+ | |
return {cancel:true}; | |
} | |
} | |
@@ -239,8 +315,24 @@ function blockUrlCallback(d) | |
var rules = block_urls.specific[tab_list[d.tabId].host_levels[level]]; | |
for (var i in rules) | |
+ { | |
if (d.url.indexOf(rules[i]) > -1) | |
+ { | |
+ if (debug_mode) | |
+ { | |
+ chrome.notifications.create('blocked', { | |
+ type: "basic", | |
+ title: "IDCAC debugging mode", | |
+ message: "Site specific block pattern found: " + rules[i], | |
+ iconUrl: "icons/48.png" | |
+ }); | |
+ } | |
+ | |
+ setSuccessBadge(d.tabId); | |
+ | |
return {cancel:true}; | |
+ } | |
+ } | |
} | |
} | |
} | |
@@ -252,6 +344,21 @@ function blockUrlCallback(d) | |
chrome.webRequest.onBeforeRequest.addListener(blockUrlCallback, {urls:["http://*/*", "https://*/*"], types:["script","stylesheet","xmlhttprequest"]}, ["blocking"]); | |
+// Detect content type (XML related Firefox bug) | |
+ | |
+chrome.webRequest.onHeadersReceived.addListener(function(d) { | |
+ if (tab_list[d.tabId]) { | |
+ d.responseHeaders.forEach(function(h) { | |
+ if (h.name == "Content-Type" || h.name == "content-type") { | |
+ xml_tabs[d.tabId] = h.value.indexOf("/xml") > -1; | |
+ } | |
+ }); | |
+ } | |
+ | |
+ return {cancel:false}; | |
+}, {urls:["http://*/*", "https://*/*"], types:["main_frame"]}, ["blocking", "responseHeaders"]); | |
+ | |
+ | |
// Reporting | |
function reportWebsite(info, tab) | |
@@ -295,20 +402,39 @@ function activateDomain(hostname, tabId, frameId) | |
status = false; | |
if (typeof r.s != 'undefined') { | |
- chrome.tabs.insertCSS(tabId, {code: r.s, frameId: frameId, matchAboutBlank: true, runAt: 'document_start'}); | |
+ chrome.tabs.insertCSS(tabId, {code: r.s, frameId: frameId, runAt: xml_tabs[tabId] ? 'document_idle' : 'document_start'}); | |
status = true; | |
} | |
else if (typeof r.c != 'undefined') { | |
- chrome.tabs.insertCSS(tabId, {code: commons[r.c], frameId: frameId, matchAboutBlank: true, runAt: 'document_start'}); | |
+ chrome.tabs.insertCSS(tabId, {code: commons[r.c], frameId: frameId, runAt: xml_tabs[tabId] ? 'document_idle' : 'document_start'}); | |
status = true; | |
} | |
if (typeof r.j != 'undefined') { | |
- chrome.tabs.executeScript(tabId, {file: 'data/js/'+(r.j > 0 ? 'common'+r.j : hostname)+'.js', frameId: frameId, matchAboutBlank: true, runAt: 'document_end'}); | |
+ chrome.tabs.executeScript(tabId, {file: 'data/js/'+(r.j > 0 ? 'common'+r.j : hostname)+'.js', frameId: frameId, runAt: xml_tabs[tabId] ? 'document_idle' : 'document_end'}); | |
status = true; | |
} | |
- return status; | |
+ if (!status) | |
+ return false; | |
+ | |
+ | |
+ setSuccessBadge(tabId); | |
+ | |
+ | |
+ // FF only: debugging mode | |
+ | |
+ if (debug_mode && !frameId) | |
+ { | |
+ chrome.notifications.create('applied', { | |
+ type: "basic", | |
+ title: "IDCAC debugging mode", | |
+ message: "Custom rule applied on " + hostname, | |
+ iconUrl: "icons/48.png" | |
+ }); | |
+ } | |
+ | |
+ return true; | |
} | |
@@ -321,7 +447,7 @@ function doTheMagic(tabId, frameId, anotherTry) | |
return; | |
// Common CSS rules | |
- chrome.tabs.insertCSS(tabId, {file: "data/css/common.css", frameId: frameId || 0, matchAboutBlank: true, runAt: 'document_start'}, function() { | |
+ chrome.tabs.insertCSS(tabId, {file: "data/css/common.css", frameId: frameId || 0, runAt: xml_tabs[tabId] ? 'document_idle' : 'document_start'}, function() { | |
// A failure? Retry. | |
@@ -331,12 +457,16 @@ function doTheMagic(tabId, frameId, anotherTry) | |
if (currentTry == 5) | |
return; | |
- return doTheMagic(tabId, frameId || 0, currentTry + 1); | |
+ setTimeout(function() { | |
+ doTheMagic(tabId, frameId || 0, currentTry + 1) | |
+ }, 300); | |
+ | |
+ return; | |
} | |
// Common social embeds | |
- chrome.tabs.executeScript(tabId, {file:'data/js/embeds.js', frameId: frameId || 0, matchAboutBlank: true, runAt: 'document_end'}, function() {}); | |
+ chrome.tabs.executeScript(tabId, {file:'data/js/embeds.js', frameId: frameId || 0, runAt: xml_tabs[tabId] ? 'document_idle' : 'document_end'}, function() {}); | |
if (activateDomain(tab_list[tabId].hostname, tabId, frameId || 0)) | |
return; | |
@@ -346,7 +476,7 @@ function doTheMagic(tabId, frameId, anotherTry) | |
return true; | |
// Common JS rules when custom rules don't exist | |
- chrome.tabs.executeScript(tabId, {file:'data/js/common.js', frameId: frameId || 0, matchAboutBlank: true, runAt: 'document_end'}, function() {}); | |
+ chrome.tabs.executeScript(tabId, {file:'data/js/common.js', frameId: frameId || 0, runAt: xml_tabs[tabId] ? 'document_idle' : 'document_end'}, function() {}); | |
}); | |
} | |
@@ -355,6 +485,8 @@ chrome.webNavigation.onCommitted.addListener(function(tab) { | |
if (tab.frameId > 0) | |
return; | |
+ resetBadge(tab.tabId); | |
+ | |
tab_list[tab.tabId] = getPreparedTab(tab); | |
doTheMagic(tab.tabId); | |
@@ -367,31 +499,39 @@ chrome.webRequest.onResponseStarted.addListener(function(tab) { | |
}, {urls: ['<all_urls>'], types: ['sub_frame']}); | |
+// FF only | |
+ | |
+chrome.webRequest.onResponseStarted.addListener(function(tab) { | |
+ doTheMagic(tab.tabId, tab.frameId); | |
+}, {urls: ['https://consent.google.com/*', 'https://consent.youtube.com/*'], types: ['beacon']}); | |
+ | |
+ | |
// Update notification | |
chrome.runtime.onInstalled.addListener(function(d){ | |
if (d.reason == "update" && chrome.runtime.getManifest().version > d.previousVersion) | |
{ | |
+ chrome.browserAction.setIcon({path: "icons/32.gif"}); | |
+ | |
+ setTimeout(function(){ | |
+ chrome.browserAction.setIcon({path: "icons/32.png"}); | |
+ }, 4000); | |
+ | |
chrome.tabs.create({url:"https://www.i-dont-care-about-cookies.eu/whats-new/acquisition/"}); | |
// chrome.notifications.create('update', { | |
// type: "basic", | |
// title: "Big summer update - I don't care about cookies", | |
// message: "Support the project, please. Visit i-dont-care-about-cookies.eu", | |
-// iconUrl: "icons/48.png"/*, | |
-// buttons:[{title: chrome.i18n.getMessage("menuSupport")}]*/ | |
+// iconUrl: "icons/48.png" | |
// }); | |
-// | |
-// // chrome.notifications.onButtonClicked.addListener(function(){ | |
-// // chrome.tabs.create({url:"https://www.i-dont-care-about-cookies.eu/"}); | |
-// // }); | |
} | |
if (d.reason == "install") { | |
chrome.storage.local.get('is_installed', function(r) { | |
if (typeof r.is_installed == 'undefined') { | |
chrome.storage.local.set({'is_installed': true}, function() { | |
-// chrome.tabs.create({url:"https://www.i-dont-care-about-cookies.eu"}); | |
+ // chrome.tabs.create({url:"https://www.i-dont-care-about-cookies.eu"}); | |
}); | |
} | |
}); | |
@@ -428,6 +568,8 @@ chrome.runtime.onMessage.addListener(function(request, info, sendResponse) { | |
chrome.tabs.create({url:"https://www.i-dont-care-about-cookies.eu/"}); | |
else if (request.command == 'open_options_page') | |
chrome.tabs.create({url:chrome.runtime.getURL('data/options.html')}); | |
+ else if (request.command == 'cookie_warning_dismissed' && request.url) | |
+ cookie_warning_dismissed_domains[getHostname(request.url, true)] = true; | |
} | |
} | |
}); | |
\ No newline at end of file | |
diff --git a/src/data/js/forbes.com.js b/src/data/js/forbes.com.js | |
deleted file mode 100644 | |
index bc55dd7..0000000 | |
--- a/src/data/js/forbes.com.js | |
+++ /dev/null | |
@@ -1,20 +0,0 @@ | |
-function isValidUrl(toURL) { | |
- return (toURL || '').match(/^(?:https?:?\/\/)?(?:[^.(){}\\\/]*)?\.?forbes\.com(?:\/|\?|$)/i); | |
-} | |
- | |
-function getUrlParameter(name) { | |
- name = name.replace(/[\[]/, '\\[').replace(/[\]]/, '\\]'); | |
- var regex = new RegExp('[\\?&]' + name + '=([^&#]*)'); | |
- var results = regex.exec(location.search); | |
- return results === null ? '' : decodeURIComponent(results[1].replace(/\+/g, ' ')); | |
-} | |
- | |
-if (/\/consent\/\?toURL\=/.test(document.location.href)) | |
-{ | |
- document.cookie = "notice_preferences=2:"; | |
- | |
- setTimeout(function() { | |
- var toURL = getUrlParameter("toURL"); | |
- document.location.href = isValidUrl(toURL) ? toURL : "https://www.forbes.com/"; | |
- }, 1000); | |
-} | |
\ No newline at end of file | |
diff --git a/src/data/js/murciaregion.com.js b/src/data/js/murciaregion.com.js | |
deleted file mode 100644 | |
index 119b356..0000000 | |
--- a/src/data/js/murciaregion.com.js | |
+++ /dev/null | |
@@ -1,2 +0,0 @@ | |
-if (document.querySelector('a[href*="IncluirIPCookies"]')) | |
- document.location.href = '/tusfotos/IncluirIPCookies.php'; | |
\ No newline at end of file | |
diff --git a/src/data/js/npostart.nl.js b/src/data/js/npostart.nl.js | |
deleted file mode 100644 | |
index c1b8b99..0000000 | |
--- a/src/data/js/npostart.nl.js | |
+++ /dev/null | |
@@ -1,18 +0,0 @@ | |
-var t = 0; | |
- | |
-var i = setInterval(function(){ | |
- var e = document.querySelectorAll('.ccm_col_content_cookieitem-radiowrap > label:first-child .ccm_col_content_cookieitem-radiocheck'); | |
- t++; | |
- | |
- if (e.length > 0) | |
- { | |
- e.forEach(function(element) { | |
- element.click(); | |
- }); | |
- | |
- document.querySelector('button.ccm_btn').click(); | |
- } | |
- | |
- if (e.length > 0 || t == 200) | |
- clearInterval(i); | |
-}, 500); | |
\ No newline at end of file | |
diff --git a/src/data/js/pentaxforum.nl.js b/src/data/js/pentaxforum.nl.js | |
deleted file mode 100644 | |
index d5c579f..0000000 | |
--- a/src/data/js/pentaxforum.nl.js | |
+++ /dev/null | |
@@ -1,2 +0,0 @@ | |
-if (/cookies\.php/.test(document.location.href)) | |
- document.getElementsByTagName('input')[1].click(); | |
\ No newline at end of file | |
diff --git a/src/data/js/washingtonpost.com.js b/src/data/js/washingtonpost.com.js | |
deleted file mode 100644 | |
index 78d0480..0000000 | |
--- a/src/data/js/washingtonpost.com.js | |
+++ /dev/null | |
@@ -1,15 +0,0 @@ | |
-if (/\/gdpr-consent\//.test(document.location.href)) | |
-{ | |
- var i = setInterval(function() { | |
- var checkbox = document.querySelector('.gdpr-consent-container .consent-page:not(.hide) #agree'); | |
- | |
- if (checkbox) | |
- { | |
- checkbox.checked = true; | |
- checkbox.dispatchEvent(new Event('change')); | |
- | |
- document.querySelector('.gdpr-consent-container .consent-page:not(.hide) .continue-btn.button.accept-consent').click(); | |
- clearInterval(i); | |
- } | |
- }, 500); | |
-} | |
\ No newline at end of file | |
diff --git a/src/icons/32.gif b/src/icons/32.gif | |
new file mode 100644 | |
index 0000000..e7f4bf5 | |
Binary files /dev/null and b/src/icons/32.gif differ | |
diff --git a/src/manifest.json b/src/manifest.json | |
index 96c96bb..d321e9f 100644 | |
--- a/src/manifest.json | |
+++ b/src/manifest.json | |
@@ -1,42 +1,46 @@ | |
{ | |
-"update_url": "https://clients2.google.com/service/update2/crx", | |
- | |
- "manifest_version": 2, | |
- "name": "__MSG_extensionName__", | |
- "short_name": "__MSG_extensionDescription__", | |
- "default_locale": "en", | |
- "version": "3.4.3", | |
- "icons": { | |
- "16": "icons/16.png", | |
- "48": "icons/48.png", | |
- "128": "icons/128.png" | |
- }, | |
- "author": "Daniel Kladnik @ kiboke studio", | |
- "permissions": [ | |
- "tabs", | |
- "storage", | |
- "http://*/*", | |
- "https://*/*", | |
- "notifications", | |
- "webRequest", | |
- "webRequestBlocking", | |
- "webNavigation" | |
- ], | |
- "background": { | |
- "scripts": [ | |
- "data/rules.js", | |
- "data/context-menu.js" | |
- ] | |
- }, | |
- "options_ui": { | |
- "page": "data/options.html", | |
- "chrome_style": true | |
- }, | |
- "browser_action": { | |
- "default_popup": "data/menu/index.html", | |
- "default_icon": { | |
- "16": "icons/16.png", | |
- "32": "icons/32.png" | |
- } | |
+ "manifest_version": 2, | |
+ "name": "__MSG_extensionName__", | |
+ "short_name": "__MSG_extensionDescription__", | |
+ "default_locale": "en", | |
+ "version": "3.4.3", | |
+ "applications": { | |
+ "gecko": { | |
+ "id": "jid1-KKzOGWgsW3Ao4Q@jetpack", | |
+ "strict_min_version": "56.0" | |
} | |
+ }, | |
+ "icons": { | |
+ "16": "icons/16.png", | |
+ "48": "icons/48.png", | |
+ "128": "icons/128.png" | |
+ }, | |
+ "author": "Daniel Kladnik @ kiboke studio", | |
+ "permissions": [ | |
+ "tabs", | |
+ "storage", | |
+ "http://*/*", | |
+ "https://*/*", | |
+ "notifications", | |
+ "webRequest", | |
+ "webRequestBlocking", | |
+ "webNavigation" | |
+ ], | |
+ "background": { | |
+ "scripts": [ | |
+ "data/rules.js", | |
+ "data/context-menu.js" | |
+ ] | |
+ }, | |
+ "options_ui": { | |
+ "page": "data/options.html", | |
+ "browser_style": true | |
+ }, | |
+ "browser_action": { | |
+ "default_popup": "data/menu/index.html", | |
+ "default_icon": { | |
+ "16": "icons/16.png", | |
+ "32": "icons/32.png" | |
+ } | |
+ } | |
} | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment