diff --git a/scripts/background.js b/scripts/background.js index cf721ed..0aeab2c 100644 --- a/scripts/background.js +++ b/scripts/background.js @@ -169,40 +169,6 @@ const updateCache = (hostname, state) => { }); }; -/** - * @function updateState - * @description Set an extension state - * - * @param {string} [tabId] - * @param {string} [state] - */ - -const updateState = (tabId, state) => { - switch (state) { - case "loading": - chrome.tabs.insertCSS( - tabId, - { - file: "styles/content.css", - runAt: "document_start", - }, - () => chrome.runtime.lastError - ); - break; - case "ready": - chrome.tabs.removeCSS( - tabId, - { - file: "styles/content.css", - }, - () => chrome.runtime.lastError - ); - break; - default: - break; - } -}; - /** * @description Listens to messages */ @@ -243,9 +209,6 @@ chrome.runtime.onMessage.addListener((request, sender, responseCallback) => { case "UPDATE_CACHE": updateCache(request.hostname, request.state); break; - case "UPDATE_STATE": - if (hasPermission) updateState(tabId, request.state); - break; default: break; } diff --git a/scripts/content.js b/scripts/content.js index 5e25d1b..6e7e4b2 100644 --- a/scripts/content.js +++ b/scripts/content.js @@ -22,14 +22,6 @@ const dispatch = chrome.runtime.sendMessage; let intervalId = 0; -/** - * @var loading - * @description Is extension loading? - * @type {boolean} - */ - -let loading = true; - /** * @var selectorsFromCache * @description Array of selectors @@ -59,7 +51,6 @@ const fix = () => { if (body) body.style.setProperty("overflow-y", "unset", "important"); if (facebook) facebook.style.setProperty("position", "unset", "important"); if (html) html.style.setProperty("overflow-y", "unset", "important"); - if (!loading) dispatch({ state: "ready", type: "UPDATE_STATE" }); }; /** @@ -99,10 +90,7 @@ const removeFromCache = () => { if (element) { const tagName = element.tagName.toUpperCase(); - if (!["BODY", "HTML"].includes(tagName)) { - element.remove(); - loading = false; - } + if (!["BODY", "HTML"].includes(tagName)) element.remove(); } } }; @@ -122,7 +110,6 @@ const removeFromNetwork = () => { if (!["BODY", "HTML"].includes(tagName)) { element.remove(); - loading = false; dispatch({ hostname: document.location.hostname, state: { matches: [selector] }, @@ -139,10 +126,6 @@ const removeFromNetwork = () => { */ const runTasks = () => { - if (attempts >= 5 || selectorsFromCache.length === 0) { - loading = false; - } - if (attempts <= 20) { fix(); removeFromCache(); @@ -166,7 +149,6 @@ dispatch( dispatch({ type: "ENABLE_POPUP" }); if (enabled) { - dispatch({ state: "loading", type: "UPDATE_STATE" }); selectorsFromCache = matches; dispatch({ type: "ENABLE_ICON" }); dispatch({ type: "GET_LIST" }, null, ({ selectors }) => { diff --git a/styles/content.css b/styles/content.css deleted file mode 100644 index 036a83d..0000000 --- a/styles/content.css +++ /dev/null @@ -1,9 +0,0 @@ -body { - opacity: 0; -} - -@media (prefers-color-scheme: dark) { - html { - background-color: #424242; - } -}