remove the background image
const r = rules[i]; if(!r.style) continue; const bg = r.style.getPropertyValue('background-image') || r.style.getPropertyValue('background'); if(bg){ // Save a tiny copy of the rule so we can undo history.push({sheet, index:i, cssText: r.cssText}); try{ r.style.removeProperty('background-image'); r.style.removeProperty('background'); removedRules++; } catch(e){ /* ignore */ } } } } log(`Removed background declarations from ${removedRules} CSS rule(s)`); }); removeAllBtn.addEventListener('click', ()=>{ // aggressive: remove from inline on all elements + try stylesheets selectorIn.value = ''; removeInlineBtn.click(); removeCSSBtn.click(); removeComputedBtn.click(); log('Performed aggressive full-page background-image removal'); }); undoBtn.addEventListener('click', ()=>{ const last = history.pop(); if(!last){ log('Nothing to undo'); return; } // If it was an inline change if(last.el && 'prop' in last){ if(last.prev === null) last.el.style.removeProperty(last.prop); else last.el.style.setProperty(last.prop, last.prev); log('Undid one inline change'); return; } // If it was a stylesheet change if(last.sheet && typeof last.index === 'number'){ try{ // Try to re-insert the rule; if not possible just append last.sheet.insertRule(last.cssText, last.sheet.cssRules.length); log('Restored one CSS rule (best-effort)'); return; }catch(e){ log('Could not restore CSS rule (cross-origin or read-only)'); return; } } }); copyLogBtn.addEventListener('click', async ()=>{ try{ await navigator.clipboard.writeText(logEl.value); log('Log copied to clipboard'); } catch(e){ log('Could not copy log — permission denied'); } }); clearLogBtn.addEventListener('click', ()=>{ logEl.value = ''; log('Log cleared'); }); // initial log entry log('Tool ready — test on the demo area or use selector "body" to remove page background'); })();