diff options
| author | sameerasw <[email protected]> | 2025-05-31 12:13:03 +0530 | 
|---|---|---|
| committer | sameerasw <[email protected]> | 2025-05-31 12:13:03 +0530 | 
| commit | ac6b9099a09052fbe0172000838a1bf966ce25a4 (patch) | |
| tree | ff0c0cc3c135cf7d637225be31897867fe3b9685 | |
| parent | 176a8a76245ed60d347d445441e1b75a31f16461 (diff) | |
Added fallback bg when transparency toggle is off.
| -rw-r--r-- | background.js | 32 | 
1 files changed, 31 insertions, 1 deletions
diff --git a/background.js b/background.js index 95daea2..1a22365 100644 --- a/background.js +++ b/background.js @@ -725,6 +725,7 @@ async function applyCSS(tabId, hostname, features) {    let skippedHoverFeatures = 0;    let skippedFooterFeatures = 0;    let skippedDisabledFeatures = 0; +  let totalTransparencyFeatures = 0;    for (const [feature, css] of Object.entries(features)) {      const isTransparencyFeature = feature @@ -733,6 +734,11 @@ async function applyCSS(tabId, hostname, features) {      const isHoverFeature = feature.toLowerCase().includes("hover");      const isFooterFeature = feature.toLowerCase().includes("footer"); +    // Count total transparency features +    if (isTransparencyFeature) { +      totalTransparencyFeatures++; +    } +      // Skip any transparency feature if disableTransparency is enabled globally      if (globalSettings.disableTransparency && isTransparencyFeature) {        console.log(`DEBUG: Skipping transparency feature: ${feature}`); @@ -762,11 +768,35 @@ async function applyCSS(tabId, hostname, features) {      } else {        console.log(`DEBUG: Feature disabled in site settings: ${feature}`);        skippedDisabledFeatures++; +      // Count disabled transparency features for site-specific logic +      if (isTransparencyFeature) { +        skippedTransparencyFeatures++; +      }      }    } +  // Check if transparency is effectively disabled (globally or all site transparency features disabled) +  const transparencyDisabled = +    globalSettings.disableTransparency || +    (totalTransparencyFeatures > 0 && +      skippedTransparencyFeatures === totalTransparencyFeatures); + +  // Add background color CSS if transparency is disabled +  if (transparencyDisabled) { +    const backgroundCSS = ` +/* ZenInternet: Background color when transparency is disabled */ +body { +    background-color: light-dark(#fff, #111) !important; +} +`; +    combinedCSS += backgroundCSS; +    console.log( +      `DEBUG: Added background color CSS due to disabled transparency` +    ); +  } +    console.log( -    `DEBUG: CSS Summary - included: ${includedFeatures}, skipped transparency: ${skippedTransparencyFeatures}, skipped hover: ${skippedHoverFeatures}, skipped footer: ${skippedFooterFeatures}, skipped disabled: ${skippedDisabledFeatures}` +    `DEBUG: CSS Summary - included: ${includedFeatures}, skipped transparency: ${skippedTransparencyFeatures}, skipped hover: ${skippedHoverFeatures}, skipped footer: ${skippedFooterFeatures}, skipped disabled: ${skippedDisabledFeatures}, transparency disabled: ${transparencyDisabled}`    );    if (combinedCSS) {  | 
