|
(function() { |
|
// Function to apply grayscale to images |
|
function applyGrayscaleCSS() { |
|
const style = document.createElement('style'); |
|
style.innerHTML = ` |
|
img { filter: grayscale(100%) !important; transition: filter 0.5s !important; } |
|
a { color: #000 !important; } |
|
svg, img[src*=".svg"], img[src*=".gif"], img[src*="logo"] { filter: grayscale(100%) !important; } |
|
`; |
|
document.head.appendChild(style); |
|
} |
|
|
|
// Function to classify and change text color |
|
function changeTextColor(element) { |
|
const style = window.getComputedStyle(element); |
|
const color = style.color.match(/\d+/g).map(Number); |
|
const [r, g, b] = color; |
|
|
|
if (r + g + b > 300) { // Not dark enough |
|
element.style.color = '#222 !important'; |
|
} |
|
|
|
if (style.fontWeight === 'bold' || parseInt(style.fontWeight) >= 700) { |
|
element.style.color = '#000 !important'; |
|
} |
|
} |
|
|
|
// Function to handle button-like links |
|
function handleLinks() { |
|
document.querySelectorAll('a').forEach(a => { |
|
if (a.className.includes('btn') || a.id.includes('btn') || a.className.includes('button') || a.id.includes('button')) { |
|
a.style.backgroundColor = '#FFFFFF'; |
|
a.style.color = '#000'; |
|
a.style.border = '2px solid #000'; |
|
a.style.fontWeight = 'bold'; |
|
a.style.padding = '5px 10px'; |
|
a.style.textDecoration = 'none'; |
|
a.style.display = 'inline-block'; |
|
a.addEventListener('mousedown', () => a.style.transform = 'scale(0.98)'); |
|
a.addEventListener('mouseup', () => a.style.transform = 'scale(1)'); |
|
} else { |
|
a.style.fontWeight = 'bold'; |
|
a.style.color = '#000 !important'; |
|
} |
|
|
|
// Change background color for styled anchor elements |
|
const bgColor = window.getComputedStyle(a).backgroundColor; |
|
const rgb = bgColor.match(/\d+/g).map(Number); |
|
const [r, g, b] = rgb; |
|
|
|
if (r + g + b > 300) { // Light colors |
|
a.style.backgroundColor = '#FFFFFF !important'; |
|
} |
|
}); |
|
} |
|
|
|
// Function to create SVG placeholder |
|
function createPlaceholderSVG(width, height) { |
|
const svg = ` |
|
<svg class="svgbob" viewBox="0 0 ${width} ${height}" xmlns="http://www.w3.org/2000/svg"> |
|
<style> |
|
.svgbob line { stroke: #1DA1F2; stroke-width: 1; } |
|
.svgbob rect.backdrop { fill: white; } |
|
</style> |
|
<rect class="backdrop" width="${width}" height="${height}"/> |
|
<line class="solid" x1="0" y1="0" x2="${width}" y2="${height}"/> |
|
</svg>`; |
|
return `data:image/svg+xml;base64,${btoa(svg)}`; |
|
} |
|
|
|
// Apply changes |
|
function applyChanges() { |
|
// Apply grayscale to images |
|
applyGrayscaleCSS(); |
|
|
|
// Change text color |
|
document.querySelectorAll('body *').forEach(changeTextColor); |
|
|
|
// Handle button-like links |
|
handleLinks(); |
|
|
|
// Replace images and iframes with placeholders |
|
document.querySelectorAll('img, iframe, video, [class*="ad"], [id*="ad"]').forEach(el => { |
|
const computedStyle = window.getComputedStyle(el); |
|
const width = el.clientWidth || 100; |
|
const height = el.clientHeight || 100; |
|
el.style.backgroundColor = 'white !important'; |
|
el.src = createPlaceholderSVG(width, height); |
|
}); |
|
|
|
// Handle specific ad domains |
|
document.querySelectorAll('img[src*="doubleclick.net"], iframe[src*="doubleclick.net"], img[src*="googlesyndication.com"], iframe[src*="googlesyndication.com"]').forEach(el => { |
|
const computedStyle = window.getComputedStyle(el); |
|
const width = el.clientWidth || 100; |
|
const height = el.clientHeight || 100; |
|
el.style.backgroundColor = 'white !important'; |
|
el.src = createPlaceholderSVG(width, height); |
|
}); |
|
|
|
// Handle text selection highlighting |
|
const selectionStyle = document.createElement('style'); |
|
selectionStyle.innerHTML = '::selection { background: #FFD700; }'; |
|
document.head.appendChild(selectionStyle); |
|
|
|
// Make buttons stand out |
|
document.querySelectorAll('button').forEach(button => { |
|
button.style.backgroundColor = '#FFFFFF'; |
|
button.style.color = '#000'; |
|
button.style.border = '2px solid #000'; |
|
button.style.fontWeight = 'bold'; |
|
button.addEventListener('mousedown', () => button.style.transform = 'scale(0.98)'); |
|
button.addEventListener('mouseup', () => button.style.transform = 'scale(1)'); |
|
}); |
|
|
|
// Change background color of DIVs if not light grey |
|
document.querySelectorAll('div').forEach(div => { |
|
const bgColor = window.getComputedStyle(div).backgroundColor; |
|
const rgb = bgColor.match(/\d+/g).map(Number); |
|
const [r, g, b] = rgb; |
|
|
|
if (r + g + b > 540) { // Light grey threshold |
|
div.style.backgroundColor = '#FFFFFF !important'; |
|
} |
|
}); |
|
} |
|
|
|
applyChanges(); |
|
})(); |