Skip to content

Commit

Permalink
Cleanup (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
OhMyGuus authored Nov 8, 2022
1 parent 1c64f6e commit 872ec61
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 69 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"max-len": 0,
"no-tabs": 0,
"require-jsdoc": 0,
"no-multi-str": 0
"no-multi-str": 0,
"guard-for-in":0
}
}
15 changes: 7 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
tags:
- 'v*.*.*'
- "v*.*.*"

jobs:
build:
Expand Down Expand Up @@ -63,25 +63,24 @@ jobs:
apiKey: ${{ secrets.AMO_SIGN_KEY }}
apiSecret: ${{ secrets.AMO_SIGN_SECRET }}
timeout: 900000



- name: Sleep for 15 minutes
run: sleep 15m
shell: bash

- name: Download xpi
run: |
wget https://addons.mozilla.org/firefox/downloads/latest/istilldontcareaboutcookies/istilldontcareaboutcookies-latest.xpi --trust-server-names
wget https://addons.mozilla.org/firefox/downloads/latest/istilldontcareaboutcookies/istilldontcareaboutcookies-latest.xpi --trust-server-names
- uses: actions/upload-artifact@v3
with:
name: ISDCAC-firefox-signed
path: istilldontcareaboutcookies-*.xpi

- name: Rename source xpi
run: |
mv ISDCAC.xpi ISDCAC-firefox-source.zip
- name: "Create Release"
uses: softprops/action-gh-release@v1
env:
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Also having it on Github allows us to improve the code & add support for website
- [**Chrome** Web Store](https://chrome.google.com/webstore/detail/i-still-dont-care-about-c/edibdbjcniadpccecjdfdjjppcpchdlm)
- [**Edge** Add-ons](https://microsoftedge.microsoft.com/addons/detail/i-still-dont-care-about-/kkacdgacpkediooahopgcbdahlpipheh)


## Manual installation

- [Installation guide for **Firefox**](https://github.com/OhMyGuus/I-Dont-Care-About-Cookies/wiki/Firefox-installation-guide)
Expand Down
22 changes: 10 additions & 12 deletions src/data/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { blockUrls, commons, commonJSHandlers, rules } from "./rules.js";
let initialized = false;
let cachedRules = {};
let tabList = {};
let xmlTabs = {};
const xmlTabs = {};
let lastDeclarativeNetRuleId = 1;
let settings = { statusIndicators: true, whitelistedDomains: {} };
const isManifestV3 = chrome.runtime.getManifest().manifest_version == 3;

// Badges
function setBadge(tabId, text) {
var chromeAction = chrome?.browserAction ?? chrome?.action;
const chromeAction = chrome?.browserAction ?? chrome?.action;

if (!chromeAction || !settings.statusIndicators) return;

Expand All @@ -31,10 +31,6 @@ function setDisabledBadge(tabId) {
setBadge(tabId, "⛔");
}

function resetBadge(tabId) {
setBadge(tabId);
}

// Common functions
function getHostname(url, cleanup) {
try {
Expand Down Expand Up @@ -62,15 +58,15 @@ function updateSettings() {
settings = storedSettings;

if (isManifestV3) {
await UpdateWhitelistRules();
await updateWhitelistRules();
}
resolve();
}
);
});
}

async function UpdateWhitelistRules() {
async function updateWhitelistRules() {
if (!isManifestV3) {
console.warn("Called unsupported function");
return;
Expand Down Expand Up @@ -148,7 +144,7 @@ async function toggleWhitelist(tab) {
}
});
if (isManifestV3) {
await UpdateWhitelistRules();
await updateWhitelistRules();
}
}

Expand Down Expand Up @@ -209,7 +205,9 @@ async function recreateTabList(magic) {

if (magic) {
for (const i in tabList) {
doTheMagic(tabList[i].id);
if (tabList.hasOwnProperty(i)) {
doTheMagic(tabList[i].id);
}
}
}
}
Expand All @@ -218,7 +216,7 @@ chrome.tabs.onCreated.addListener(onCreatedListener);
chrome.tabs.onUpdated.addListener(onUpdatedListener);
chrome.tabs.onRemoved.addListener(onRemovedListener);

//chrome.runtime.onStartup.addListener(async () => await initialize(true));
// chrome.runtime.onStartup.addListener(async () => await initialize(true));
chrome.runtime.onInstalled.addListener(async () => await initialize(true));

// URL blocking
Expand Down Expand Up @@ -655,7 +653,7 @@ function executeScript(injection, callback) {
}

async function loadCachedRules() {
//TODO: Load cached rules for V3 to improve speed (Requires testing to see if this actually is faster for v3)
// TODO: Load cached rules for V3 to improve speed (Requires testing to see if this actually is faster for v3)
cachedRules = {};
}

Expand Down
2 changes: 1 addition & 1 deletion src/data/js/2_sessionStorageHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function getItem(hostname) {
return false;
}

const h = document.location.hostname.replace(/^w{2,3}\d*\./i, "");
const hostname = document.location.hostname.replace(/^w{2,3}\d*\./i, "");
const item = getItem(hostname);

if (item) {
Expand Down
76 changes: 36 additions & 40 deletions src/data/js/5_clickHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ function _ev(selector, container, full) {

let currentChainElement = 0;

function _chain() {
const argumentsLength = arguments.length;
let flagUnique = false,
flagOptional = false,
element;
function _chain(...selectors) {
const argumentsLength = selectors.length;
let flagUnique = false;
let flagOptional = false;
let element;

for (let i = currentChainElement; i < argumentsLength; i++) {
// An argument can be a list of flags valid for all the following arguments

if (/^FLAG\:/.test(arguments[i])) {
arguments[i]
if (/^FLAG\:/.test(selectors[i])) {
selectors[i]
.split(":")[1]
.split(",")
.forEach(function (flag) {
Expand All @@ -77,16 +77,16 @@ function _chain() {
}

if (flagUnique) {
arguments[i] += arguments[i].startsWith("//")
selectors[i] += selectors[i].startsWith("//")
? '[not(contains(@class, "' + classname + '"))]'
: ":not(" + classname + ")";
}

if (i == argumentsLength - 1) {
return arguments[i];
return selectors[i];
}

element = _sl(arguments[i]);
element = _sl(selectors[i]);

if (!element) {
if (flagOptional) {
Expand Down Expand Up @@ -7183,14 +7183,11 @@ function getSelector(host) {
case "tourisme-lodevois-larzac.fr":
return '.fw_cookies_btns > a[onclick="fw_cookies_policy_deny_all();"]';
case "swiss.com":
return '#cm-acceptNone';
return "#cm-acceptNone";
case "plateuptools.com":
return _chain(
'#c-s-bn',
'#s-rall-bn'
);
return _chain("#c-s-bn", "#s-rall-bn");
case "dlive.tv":
return '#asfg > div';
return "#asfg > div";
case "vr.fi":
return 'button[data-testid="necessary"]';
}
Expand All @@ -7213,32 +7210,31 @@ function searchLoop(counter, host) {
const response = getSelector(host);

if (response) {
let clickCounter = 0,
clickLoop = setInterval(function () {
const element =
typeof response == "string" ? _sl(response) : response;

if (
element &&
element.click &&
!element.classList.contains(classname)
) {
element.classList.add(classname);

// Give some more time for the DOM to setup properly
setTimeout(function () {
element.click();
}, 500);

let clickCounter = 0;
const clickLoop = setInterval(function () {
const element = typeof response == "string" ? _sl(response) : response;

if (
element &&
element.click &&
!element.classList.contains(classname)
) {
element.classList.add(classname);

// Give some more time for the DOM to setup properly
setTimeout(function () {
element.click();
}, 500);

clearInterval(clickLoop);
} else {
clickCounter++;

if (clickCounter > 50) {
clearInterval(clickLoop);
} else {
clickCounter++;

if (clickCounter > 50) {
clearInterval(clickLoop);
}
}
}, 200);
}
}, 200);
} else if (counter < 200) {
searchLoop(counter + 1, host);
}
Expand Down
8 changes: 2 additions & 6 deletions src/data/js/8_googleHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ function _sl(selector, container) {
return (container || document).querySelector(selector);
}

function _id(id) {
return document.getElementById(id);
}

const main_interval = setInterval(function () {
const mainInterval = setInterval(function () {
const html = _sl("html");

if (!html || /idc8_343/.test(html.className)) {
return;
}

clearInterval(main_interval);
clearInterval(mainInterval);

html.className += " idc8_343";

Expand Down

0 comments on commit 872ec61

Please sign in to comment.