Ultra Data Saver - Maximum Compression

Blocks ads, trackers, autoplay, compresses images, removes bloat. Saves 60-80% data.

이 스크립트를 설치하려면 Tampermonkey, Greasemonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램을 설치해야 합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Violentmonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey 또는 Userscripts와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 Tampermonkey와 같은 확장 프로그램이 필요합니다.

이 스크립트를 설치하려면 유저 스크립트 관리자 확장 프로그램이 필요합니다.

(이미 유저 스크립트 관리자가 설치되어 있습니다. 설치를 진행합니다!)

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 Stylus와 같은 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

이 스타일을 설치하려면 유저 스타일 관리자 확장 프로그램이 필요합니다.

(이미 유저 스타일 관리자가 설치되어 있습니다. 설치를 진행합니다!)

// ==UserScript==  
// @name         Ultra Data Saver - Maximum Compression  
// @namespace    http://tampermonkey.net/  
// @version      4.0  
// @description  Blocks ads, trackers, autoplay, compresses images, removes bloat. Saves 60-80% data.  
// @author       You  
// @match        *://*/*  
// @grant        none  
// @run-at       document-start  
// ==/UserScript==   
  
(function() {  
    'use strict';  
  
    // ==========================================  
    // CONFIGURATION - Toggle features on/off  
    // ==========================================  
    const CONFIG = {  
        blockAds: true,              // Block ad containers  
        blockTrackers: true,         // Block tracking scripts  
        blockAutoplay: true,         // Stop autoplay videos  
        compressImages: true,        // Force low-res images  
        removeWebFonts: true,        // Disable custom fonts  
        removeAnimations: true,      // Stop CSS animations  
        lazyLoadAll: true,           // Force lazy loading  
        blockSocialWidgets: true,    // Remove social buttons  
        blockComments: false,        // Remove comment sections (optional)  
        aggressiveMode: true         // Extra data saving measures  
    };  
  
    // ==========================================  
    // TRACKING & AD DOMAIN BLOCKLIST  
    // ==========================================  
    const BLOCKED_DOMAINS = [  
        'google-analytics', 'googletagmanager', 'googlesyndication',  
        'googleadservices', 'doubleclick', 'facebook.com/tr',  
        'facebook.net', 'connect.facebook', 'platform.twitter',  
        'analytics.twitter', 'linkedin.com/analytics',  
        'adsystem', 'amazon-adsystem', 'googletagservices',  
        'outbrain', 'taboola', 'scorecardresearch',  
        'quantserve', 'googletagmanager', 'hotjar',  
        'mixpanel', 'segment.io', 'amplitude',  
        'adsafeprotected', 'moatads', 'adsrvr',  
        'adnxs', 'rubiconproject', 'openx',  
        'pubmatic', 'casalemedia', 'advertising'  
    ];  
  
    const BLOCKED_SCRIPTS = [  
        'analytics', 'tracking', 'telemetry', 'metrics',  
        'advertisement', 'sponsored', 'promotion'  
    ];  
  
    // ==========================================  
    // UTILITY FUNCTIONS  
    // ==========================================  
  
    // Check if URL matches blocked patterns  
    const isBlocked = (url) => {  
        if (!url) return false;  
        const lowerUrl = url.toLowerCase();  
        return BLOCKED_DOMAINS.some(domain => lowerUrl.includes(domain)) ||  
               BLOCKED_SCRIPTS.some(script => lowerUrl.includes(script));  
    };  
  
    // Log blocking activity (remove in production)  
    const log = (msg) => {  
        // console.log('[DataSaver]', msg);  
    };  
  
    // ==========================================  
    // 1. BLOCK NETWORK REQUESTS (Fetch/XHR)  
    // ==========================================  
    if (CONFIG.blockTrackers) {  
        const originalFetch = window.fetch;  
        window.fetch = function(...args) {  
            const url = args[0] instanceof Request ? args[0].url : args[0];  
            if (isBlocked(url)) {  
                log(`Blocked fetch: ${url}`);  
                return Promise.resolve(new Response('', { status: 200 }));  
            }  
            return originalFetch.apply(this, args);  
        };  
  
        const originalXHR = window.XMLHttpRequest;  
        window.XMLHttpRequest = function() {  
            const xhr = new originalXHR();  
            const originalOpen = xhr.open;  
            xhr.open = function(method, url, ...rest) {  
                if (isBlocked(url)) {  
                    log(`Blocked XHR: ${url}`);  
                    // Override send to do nothing  
                    xhr.send = () => {};  
                }  
                return originalOpen.call(this, method, url, ...rest);  
            };  
            return xhr;  
        };  
    }  
  
    // ==========================================  
    // 2. BLOCK SCRIPT LOADING  
    // ==========================================  
    if (CONFIG.blockTrackers || CONFIG.blockAds) {  
        const originalAppendChild = Element.prototype.appendChild;  
        Element.prototype.appendChild = function(node) {  
            if (node.tagName === 'SCRIPT' && node.src && isBlocked(node.src)) {  
                log(`Blocked script: ${node.src}`);  
                return node; // Return without appending  
            }  
            return originalAppendChild.call(this, node);  
        };  
  
        const originalInsertBefore = Element.prototype.insertBefore;  
        Element.prototype.insertBefore = function(newNode, referenceNode) {  
            if (newNode.tagName === 'SCRIPT' && newNode.src && isBlocked(newNode.src)) {  
                log(`Blocked script: ${newNode.src}`);  
                return newNode;  
            }  
            return originalInsertBefore.call(this, newNode, referenceNode);  
        };  
    }  
  
    // ==========================================  
    // 3. IMAGE COMPRESSION & OPTIMIZATION  
    // ==========================================  
    if (CONFIG.compressImages) {  
        // Force low quality images  
        const compressImage = (img) => {  
            // Skip tiny icons  
            if (img.width < 50 && img.height < 50) return;  
  
            // Add compression parameters for major CDNs  
            const src = img.src;  
            if (src.includes('googleusercontent') || src.includes('ggpht')) {  
                img.src = src.replace(/=s\d+/, '=s480').replace(/=w\d+/, '=w480');  
            } else if (src.includes('cloudinary')) {  
                img.src = src.replace('/upload/', '/upload/q_auto:low,w_480/');  
            } else if (src.includes('imgur')) {  
                img.src = src.replace(/\.jpg$/, 'l.jpg').replace(/\.png$/, 'l.png');  
            }  
  
            // Lazy load all images  
            img.loading = 'lazy';  
            img.decoding = 'async';  
  
            // Reduce quality for data savings  
            if (CONFIG.aggressiveMode && !src.includes('data:image')) {  
                img.style.imageRendering = 'pixelated';  
            }  
        };  
  
        // Process existing images  
        document.querySelectorAll('img').forEach(compressImage);  
  
        // Watch for new images  
        const imgObserver = new MutationObserver((mutations) => {  
            mutations.forEach((mutation) => {  
                mutation.addedNodes.forEach((node) => {  
                    if (node.tagName === 'IMG') compressImage(node);  
                    if (node.querySelectorAll) {  
                        node.querySelectorAll('img').forEach(compressImage);  
                    }  
                });  
            });  
        });  
    }  
  
    // ==========================================  
    // 4. VIDEO & AUDIO AUTOPAY BLOCKING  
    // ==========================================  
    if (CONFIG.blockAutoplay) {  
        // Override video autoplay  
        const originalPlay = HTMLMediaElement.prototype.play;  
        HTMLMediaElement.prototype.play = function() {  
            // Only block if not user-initiated (heuristic)  
            if (!this.hasAttribute('data-user-initiated')) {  
                log('Blocked autoplay');  
                this.pause();  
                this.currentTime = 0;  
                this.muted = true;  
                this.preload = 'none';  
                return Promise.resolve();  
            }  
            return originalPlay.call(this);  
        };  
  
        // Force preload=none on all media  
        document.querySelectorAll('video, audio').forEach(media => {  
            media.preload = 'none';  
            media.autoplay = false;  
            media.muted = true;  
        });  
  
        // Block new media elements  
        const mediaObserver = new MutationObserver((mutations) => {  
            mutations.forEach((mutation) => {  
                mutation.addedNodes.forEach((node) => {  
                    if (node.tagName === 'VIDEO' || node.tagName === 'AUDIO') {  
                        node.preload = 'none';  
                        node.autoplay = false;  
                        node.muted = true;  
                    }  
                });  
            });  
        });  
    }  
  
    // ==========================================  
    // 5. REMOVE ADS & BLOAT ELEMENTS  
    // ==========================================  
    if (CONFIG.blockAds || CONFIG.aggressiveMode) {  
        const BLOAT_SELECTORS = [  
            // Ads  
            '[class*="ad-"]', '[class*="ads-"]', '[id*="ad-"]',  
            '[class*="advertisement"]', '[id*="advertisement"]',  
            'ins.adsbygoogle', '.ad-container', '.ad-wrapper',  
            // Trackers  
            '[class*="analytics"]', '[id*="analytics"]',  
            '[class*="tracking"]', '[id*="tracking"]',  
            // Social widgets  
            '.fb-like', '.fb-share', '.twitter-share',  
            '.linkedin-share', '.social-share', '.share-buttons',  
            // Popups & overlays  
            '.modal', '.popup', '.overlay', '[class*="newsletter"]',  
            '.cookie-banner', '.gdpr-banner', '.consent-banner',  
            // Comments (optional)  
            CONFIG.blockComments ? '.comments, #comments, .disqus' : '',  
            // Other bloat  
            '.related-articles', '.recommended', '.trending',  
            '.sidebar', '.widget-area', '.newsletter-signup'  
        ].filter(Boolean);  
  
        const removeBloat = () => {  
            BLOAT_SELECTORS.forEach(selector => {  
                document.querySelectorAll(selector).forEach(el => {  
                    // Don't remove if it's the main content  
                    if (el.tagName === 'ARTICLE' || el.tagName === 'MAIN') return;  
                    el.style.display = 'none';  
                    el.remove();  
                    log(`Removed: ${selector}`);  
                });  
            });  
        };  
  
        // Run immediately and periodically  
        removeBloat();  
        setInterval(removeBloat, 2000);  
    }  
  
    // ==========================================  
    // 6. DISABLE WEB FONTS  
    // ==========================================  
    if (CONFIG.removeWebFonts) {  
        // Block font loading  
        const originalFontFace = window.FontFace;  
        if (originalFontFace) {  
            window.FontFace = function(family, source, descriptors) {  
                log(`Blocked font: ${family}`);  
                return {  
                    load: () => Promise.resolve(),  
                    family: 'system-ui'  
                };  
            };  
        }  
  
        // Remove font stylesheets  
        document.querySelectorAll('link[rel="stylesheet"]').forEach(link => {  
            if (link.href && (link.href.includes('font') || link.href.includes('googleapis'))) {  
                link.remove();  
                log(`Removed font stylesheet: ${link.href}`);  
            }  
        });  
  
        // Inject system font override  
        const style = document.createElement('style');  
        style.textContent = `  
            * { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important; }  
            @font-face { font-display: swap !important; }  
        `;  
        document.head.appendChild(style);  
    }  
  
    // ==========================================  
    // 7. DISABLE ANIMATIONS  
    // ==========================================  
    if (CONFIG.removeAnimations) {  
        const style = document.createElement('style');  
        style.textContent = `  
            *, *::before, *::after {  
                animation-duration: 0.01ms !important;  
                animation-iteration-count: 1 !important;  
                transition-duration: 0.01ms !important;  
                scroll-behavior: auto !important;  
            }  
        `;  
        document.head.appendChild(style);  
    }  
  
    // ==========================================  
    // 8. FORCE LAZY LOADING  
    // ==========================================  
    if (CONFIG.lazyLoadAll) {  
        // Lazy load iframes  
        document.querySelectorAll('iframe').forEach(iframe => {  
            iframe.loading = 'lazy';  
        });  
  
        // Lazy load background images  
        const lazyStyle = document.createElement('style');  
        lazyStyle.textContent = `  
            [style*="background-image"] { content-visibility: auto; }  
        `;  
        document.head.appendChild(lazyStyle);  
    }  
  
    // ==========================================  
    // 9. SERVICE WORKER INTERCEPTION  
    // ==========================================  
    if ('serviceWorker' in navigator && CONFIG.aggressiveMode) {  
        // Unregister service workers that might cache aggressively  
        navigator.serviceWorker.getRegistrations().then(registrations => {  
            registrations.forEach(registration => {  
                // Keep legitimate SWs, unregister ad/tracking ones  
                if (registration.scope.includes('cdn') ||  
                    registration.scope.includes('ads')) {  
                    registration.unregister();  
                    log('Unregistered SW:', registration.scope);  
                }  
            });  
        });  
    }  
  
    // ==========================================  
    // 10. DATA USAGE MONITORING  
    // ==========================================  
    if (CONFIG.aggressiveMode) {  
        // Estimate data saved  
        let originalSize = 0;  
        let blockedSize = 0;  
  
        const updateStats = () => {  
            const images = document.querySelectorAll('img');  
            let currentSize = 0;  
            images.forEach(img => {  
                if (img.naturalWidth) {  
                    currentSize += (img.naturalWidth * img.naturalHeight * 3) / 1024; // KB  
                }  
            });  
        };  
  
        // Display stats (optional - remove if not needed)  
        window.addEventListener('load', () => {  
            setTimeout(() => {  
                const stats = document.createElement('div');  
                stats.style.cssText = `  
                    position: fixed;  
                    bottom: 10px;  
                    right: 10px;  
                    background: rgba(0,0,0,0.7);  
                    color: #0f0;  
                    padding: 10px;  
                    border-radius: 5px;  
                    font-size: 12px;  
                    z-index: 999999;  
                    font-family: monospace;  
                `;  
                stats.innerHTML = '💾 Data Saver: ACTIVE';  
                document.body.appendChild(stats);  
                setTimeout(() => stats.remove(), 5000);  
            }, 1000);  
        });  
    }  
  
    log('Ultra Data Saver initialized');  
  
})();