diff options
author | sameerasw <[email protected]> | 2025-05-09 01:35:35 +0530 |
---|---|---|
committer | sameerasw <[email protected]> | 2025-05-09 01:35:35 +0530 |
commit | 3badfce6d20405153864180deaa86136014b2cba (patch) | |
tree | b0deeab10a5da50d24b4ba987be27ef43991a7d3 | |
parent | 29a6a8b340e27024ba27c2ff42e4bb35599ee33e (diff) |
added global hover and footer options
-rw-r--r-- | background.js | 23 | ||||
-rw-r--r-- | data-viewer/data-viewer.html | 28 | ||||
-rw-r--r-- | data-viewer/data-viewer.js | 63 | ||||
-rw-r--r-- | popup/popup.html | 3 | ||||
-rw-r--r-- | popup/popup.js | 14 | ||||
-rw-r--r-- | shared/defaults.js | 2 |
6 files changed, 127 insertions, 6 deletions
diff --git a/background.js b/background.js index 19ef0fe..179fc23 100644 --- a/background.js +++ b/background.js @@ -27,6 +27,8 @@ const DEFAULT_SETTINGS = { whitelistMode: false, // Use blacklist mode by default for force styling whitelistStyleMode: false, // Use blacklist mode by default for regular styling disableTransparency: false, // Don't disable transparency by default + disableHover: false, // Don't disable hover effects by default + disableFooter: false, // Don't disable footers by default }; // Helper function to normalize hostnames by removing www. prefix @@ -716,12 +718,17 @@ async function applyCSS(tabId, hostname, features) { let combinedCSS = ""; let includedFeatures = 0; let skippedTransparencyFeatures = 0; + let skippedHoverFeatures = 0; + let skippedFooterFeatures = 0; let skippedDisabledFeatures = 0; for (const [feature, css] of Object.entries(features)) { const isTransparencyFeature = feature .toLowerCase() .includes("transparency"); + const isHoverFeature = feature.toLowerCase().includes("hover"); + const isFooterFeature = feature.toLowerCase().includes("footer"); + // Skip any transparency feature if disableTransparency is enabled globally if (globalSettings.disableTransparency && isTransparencyFeature) { console.log(`DEBUG: Skipping transparency feature: ${feature}`); @@ -729,6 +736,20 @@ async function applyCSS(tabId, hostname, features) { continue; } + // Skip any hover feature if disableHover is enabled globally + if (globalSettings.disableHover && isHoverFeature) { + console.log(`DEBUG: Skipping hover feature: ${feature}`); + skippedHoverFeatures++; + continue; + } + + // Skip any footer feature if disableFooter is enabled globally + if (globalSettings.disableFooter && isFooterFeature) { + console.log(`DEBUG: Skipping footer feature: ${feature}`); + skippedFooterFeatures++; + continue; + } + const isFeatureEnabled = featureSettings[feature] !== false; if (isFeatureEnabled) { combinedCSS += css + "\n"; @@ -741,7 +762,7 @@ async function applyCSS(tabId, hostname, features) { } console.log( - `DEBUG: CSS Summary - included: ${includedFeatures}, skipped transparency: ${skippedTransparencyFeatures}, skipped disabled: ${skippedDisabledFeatures}` + `DEBUG: CSS Summary - included: ${includedFeatures}, skipped transparency: ${skippedTransparencyFeatures}, skipped hover: ${skippedHoverFeatures}, skipped footer: ${skippedFooterFeatures}, skipped disabled: ${skippedDisabledFeatures}` ); if (combinedCSS) { diff --git a/data-viewer/data-viewer.html b/data-viewer/data-viewer.html index bd934e8..1d921f5 100644 --- a/data-viewer/data-viewer.html +++ b/data-viewer/data-viewer.html @@ -41,6 +41,34 @@ </div> </div> + <!-- New toggles for hover and footer effects --> + <div class="toggle-setting-container"> + <div class="toggle-container"> + <label class="toggle-switch"> + <input type="checkbox" id="disable-hover"> + <span class="slider round"></span> + </label> + <span class="toggle-label">Disable Hover Effects Globally</span> + </div> + <div class="setting-description"> + This will disable all hover animation features while keeping other styling effects active + </div> + </div> + + <div class="toggle-setting-container"> + <div class="toggle-container"> + <label class="toggle-switch"> + <input type="checkbox" id="disable-footer"> + <span class="slider round"></span> + </label> + <span class="toggle-label">Hide Footers Globally</span> + </div> + <div class="setting-description"> + This will hide page footers on websites where the feature is available + </div> + </div> + + <!-- New section for custom repository URL --> <div class="data-section"> <h2 class="section-title">Custom Styles Repository ✨</h2> diff --git a/data-viewer/data-viewer.js b/data-viewer/data-viewer.js index fc76787..89f5b2e 100644 --- a/data-viewer/data-viewer.js +++ b/data-viewer/data-viewer.js @@ -16,6 +16,9 @@ document.addEventListener("DOMContentLoaded", function () { const disableTransparencyToggle = document.getElementById( "disable-transparency" ); + // New toggle elements + const disableHoverToggle = document.getElementById("disable-hover"); + const disableFooterToggle = document.getElementById("disable-footer"); // Repository URL Elements const repositoryUrlInput = document.getElementById("repository-url"); @@ -41,6 +44,15 @@ document.addEventListener("DOMContentLoaded", function () { saveTransparencySettings(this.checked); }); + // Event listeners for new toggles + disableHoverToggle.addEventListener("change", function () { + saveHoverSettings(this.checked); + }); + + disableFooterToggle.addEventListener("change", function () { + saveFooterSettings(this.checked); + }); + // Event listener for delete all data button deleteAllButton.addEventListener("click", function () { if ( @@ -219,6 +231,52 @@ document.addEventListener("DOMContentLoaded", function () { } } + // New functions to save hover and footer settings + async function saveHoverSettings(isDisabled) { + try { + const data = await browser.storage.local.get(BROWSER_STORAGE_KEY); + const settings = data[BROWSER_STORAGE_KEY] || {}; + + // Update the disableHover setting + settings.disableHover = isDisabled; + + await browser.storage.local.set({ [BROWSER_STORAGE_KEY]: settings }); + alert( + `Hover effects have been ${ + isDisabled ? "disabled" : "enabled" + } globally. This will affect all websites.` + ); + } catch (error) { + console.error("Error saving hover settings:", error); + alert( + "An error occurred while saving the hover effects setting: " + + error.message + ); + } + } + + async function saveFooterSettings(isDisabled) { + try { + const data = await browser.storage.local.get(BROWSER_STORAGE_KEY); + const settings = data[BROWSER_STORAGE_KEY] || {}; + + // Update the disableFooter setting + settings.disableFooter = isDisabled; + + await browser.storage.local.set({ [BROWSER_STORAGE_KEY]: settings }); + alert( + `Footers have been ${ + isDisabled ? "hidden" : "shown" + } globally. This will affect all websites.` + ); + } catch (error) { + console.error("Error saving footer settings:", error); + alert( + "An error occurred while saving the footer setting: " + error.message + ); + } + } + // Export settings functionality async function exportSettings() { try { @@ -383,9 +441,12 @@ document.addEventListener("DOMContentLoaded", function () { const globalSettings = data[BROWSER_STORAGE_KEY] || {}; displayGlobalSettings(globalSettings); - // Set the disable transparency toggle state + // Set the toggle states disableTransparencyToggle.checked = globalSettings.disableTransparency || false; + // Set new toggle states + disableHoverToggle.checked = globalSettings.disableHover || false; + disableFooterToggle.checked = globalSettings.disableFooter || false; // Display skip/enable lists for both forced and non-forced websites const skipForceList = data[SKIP_FORCE_THEMING_KEY] || []; diff --git a/popup/popup.html b/popup/popup.html index 254cd9b..2b8c48d 100644 --- a/popup/popup.html +++ b/popup/popup.html @@ -14,8 +14,7 @@ <header class="app-header"> <div id="header-container"> <div class="logo-container"> - <!-- <img src="../assets/images/logo.png" alt="ZenInternet Logo" class="logo-img"> --> - <img src="https://external-preview.redd.it/the-official-logo-of-gta-vi-v0-1mq-hMopb6xLaUw4iyglIEx-nf0AVeA4hzLLS7fWvLw.png?width=640&crop=smart&auto=webp&s=1c34f0c510bf28fc66942b1e070eeb94f1fda3e9" alt="ZenInternet Logo" class="logo-img"> + <img src="../assets/images/logo.png" alt="ZenInternet Logo" class="logo-img"> <h1 class="app-title">Zen Internet</h1> </div> <div class="miniheader"> diff --git a/popup/popup.js b/popup/popup.js index 6844415..9b2cd29 100644 --- a/popup/popup.js +++ b/popup/popup.js @@ -10,6 +10,8 @@ const DEFAULT_SETTINGS = { whitelistMode: false, // Use blacklist mode by default for force styling whitelistStyleMode: false, // Use blacklist mode by default for regular styling disableTransparency: false, // Don't disable transparency by default + disableHover: false, // Don't disable hover effects by default + disableFooter: false, // Don't disable footers by default }; // Helper function to ensure all required settings exist @@ -553,6 +555,8 @@ new (class ExtensionPopup { // Check if transparency is globally disabled const isTransparencyDisabled = this.globalSettings.disableTransparency === true; + const isHoverDisabled = this.globalSettings.disableHover === true; + const isFooterDisabled = this.globalSettings.disableFooter === true; for (const [feature, css] of Object.entries(features)) { const displayFeatureName = feature.includes("-") @@ -563,7 +567,13 @@ new (class ExtensionPopup { const isTransparencyFeature = feature .toLowerCase() .includes("transparency"); - const isOverridden = isTransparencyDisabled && isTransparencyFeature; + const isHoverFeature = feature.toLowerCase().includes("hover"); + const isFooterFeature = feature.toLowerCase().includes("footer"); + + const isOverridden = + (isTransparencyDisabled && isTransparencyFeature) || + (isHoverDisabled && isHoverFeature) || + (isFooterDisabled && isFooterFeature); const featureToggle = document.createElement("div"); featureToggle.className = "feature-toggle"; @@ -585,7 +595,7 @@ new (class ExtensionPopup { featureToggle.innerHTML = toggleHTML; - // If this is a transparency feature and it's disabled globally, add a class + // If this feature is overridden by global settings, add a class if (isOverridden) { featureToggle.classList.add("overridden-feature"); } diff --git a/shared/defaults.js b/shared/defaults.js index 0c3d027..8e2f3c9 100644 --- a/shared/defaults.js +++ b/shared/defaults.js @@ -10,6 +10,8 @@ export const DEFAULT_SETTINGS = { whitelistMode: false, // Use blacklist mode by default for force styling whitelistStyleMode: false, // Use blacklist mode by default for regular styling disableTransparency: false, // Don't disable transparency by default + disableHover: false, // Don't disable hover effects by default + disableFooter: false, // Don't disable footers by default }; /** |