From 1806efb899b17407f28830454fbf9360adaf29fc Mon Sep 17 00:00:00 2001 From: marcustyphoon Date: Mon, 29 Apr 2024 01:17:22 -0700 Subject: [PATCH] Remove outdated palette button hiding code (#178) --- src/main.js | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/src/main.js b/src/main.js index c4b033b..9b413b4 100644 --- a/src/main.js +++ b/src/main.js @@ -1,34 +1,3 @@ -const delayToDocumentIdle = delayedFunction => { - document.readyState === 'complete' - ? delayedFunction() - : window.addEventListener('load', delayedFunction); -}; - -const hideChangePaletteButton = function () { - if (document.getElementById('palette-override') !== null) { - return; - } - - if ([...document.scripts].some(({ src }) => src.includes('/pop/')) === false) { - return; - } - - const toRunInPageContext = function () { - const changePaletteLabel = window.tumblr.languageData.translations['Change Palette'] || 'Change Palette'; - const textContent = `button[aria-label="${changePaletteLabel}"] { display: none !important; }`; - const style = Object.assign(document.createElement('style'), { textContent, id: 'palette-override' }); - document.head.append(style); - }; - - const scriptWithNonce = [...document.scripts].find(script => script.getAttributeNames().includes('nonce')); - const nonce = scriptWithNonce.nonce || scriptWithNonce.getAttribute('nonce'); - - const injectable = `(${toRunInPageContext.toString()})()`; - const script = Object.assign(document.createElement('script'), { nonce, textContent: injectable }); - document.documentElement.append(script); - script.remove(); -}; - const showChangePaletteButton = function () { const style = document.getElementById('palette-override'); if (style) style.remove(); @@ -50,8 +19,6 @@ const applyCurrentPalette = async function () { return; } - delayToDocumentIdle(hideChangePaletteButton); - const paletteIsBuiltIn = currentPalette.startsWith('palette:') === false; const { [currentPalette]: currentPaletteData = {} } = paletteIsBuiltIn ? await paletteData