Auto Scroll for YouTube Shorts, plus tracker remover

Auto Scroll, also skips SponsorBlock videos, thumbs down auto scrolls to next video, tracker remover from share link

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Auto Scroll for YouTube Shorts, plus tracker remover
// @namespace    http://tampermonkey.net/
// @version      5.2
// @description  Auto Scroll, also skips SponsorBlock videos, thumbs down auto scrolls to next video, tracker remover from share link
// @author       Justn
// @match        https://www.youtube.com/shorts/*
// @grant        none
// @license      MIT
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';
    let isAutoEnabled = localStorage.getItem('autoScrollEnabled') !== 'false';
    let autoScrollOnDownvote = localStorage.getItem('autoScrollOnDownvote') !== 'false';
    function saveSettings() {
        localStorage.setItem('autoScrollEnabled', isAutoEnabled);
        localStorage.setItem('autoScrollOnDownvote', autoScrollOnDownvote);
    }
    const pill = document.createElement('div');
    pill.style.position = 'fixed';
    pill.style.bottom = '20px';
    pill.style.right = '20px';
    pill.style.width = '70px';
    pill.style.height = '50px';
    pill.style.backgroundColor = isAutoEnabled ? '#ff0000' : '#666666';
    pill.style.color = 'white';
    pill.style.borderRadius = '25px';
    pill.style.display = 'flex';
    pill.style.alignItems = 'center';
    pill.style.justifyContent = 'center';
    pill.style.fontSize = '16px';
    pill.style.fontWeight = 'bold';
    pill.style.cursor = 'pointer';
    pill.style.zIndex = '9999';
    pill.style.boxShadow = '0 4px 8px rgba(0,0,0,0.3)';
    pill.style.userSelect = 'none';
    pill.textContent = isAutoEnabled ? 'AUTO' : 'OFF';
    document.body.appendChild(pill);
    function updatePill() {
        pill.textContent = isAutoEnabled ? 'AUTO' : 'OFF';
        pill.style.backgroundColor = isAutoEnabled ? '#ff0000' : '#666666';
    }
    pill.addEventListener('click', function(e) {
        e.stopPropagation();
        isAutoEnabled = !isAutoEnabled;
        saveSettings();
        updatePill();
    });
    pill.addEventListener('contextmenu', function(e) {
        e.preventDefault();
        if (window.customMenu) window.customMenu.remove();
        const menu = document.createElement('div');
        menu.style.position = 'fixed';
        menu.style.background = '#1e1e1e';
        menu.style.border = '1px solid #444';
        menu.style.borderRadius = '8px';
        menu.style.padding = '8px 0';
        menu.style.color = 'white';
        menu.style.fontSize = '13px';
        menu.style.zIndex = '10000';
        menu.style.boxShadow = '0 4px 12px rgba(0,0,0,0.3)';
        menu.style.minWidth = '180px';
        function createItem(text, checked, callback) {
            const item = document.createElement('div');
            item.style.padding = '10px 16px';
            item.style.cursor = 'pointer';
            item.style.whiteSpace = 'nowrap';
            item.textContent = (checked ? '✓ ' : '○ ') + text;
            item.onmouseover = function() { item.style.background = '#333'; };
            item.onmouseout = function() { item.style.background = 'transparent'; };
            item.onclick = function() {
                callback();
                saveSettings();
                menu.remove();
            };
            menu.appendChild(item);
        }
        createItem('Auto scroll on thumbs down', autoScrollOnDownvote, function() {
            autoScrollOnDownvote = !autoScrollOnDownvote;
        });
        document.body.appendChild(menu);
        window.customMenu = menu;
        setTimeout(function() {
            const menuRect = menu.getBoundingClientRect();
            let left = e.pageX - 90;
            let top = e.pageY - menuRect.height - 10;
            if (left < 10) left = 10;
            if (left + menuRect.width > window.innerWidth - 10) left = window.innerWidth - menuRect.width - 10;
            if (top < 10) top = e.pageY + 10;
            if (top + menuRect.height > window.innerHeight - 10) top = window.innerHeight - menuRect.height - 10;
            menu.style.left = left + 'px';
            menu.style.top = top + 'px';
        }, 0);
        document.addEventListener('click', function() { menu.remove(); }, { once: true });
    });
    function goToNext() {
        const event = new KeyboardEvent('keydown', {
            key: 'ArrowDown',
            code: 'ArrowDown',
            keyCode: 40,
            which: 40,
            bubbles: true
        });
        document.dispatchEvent(event);
    }
    const observer = new MutationObserver(function() {
        const downvoteBtns = document.querySelectorAll('button[aria-label*="Dislike this video"], button[aria-label*="dislike"][aria-pressed]');
        downvoteBtns.forEach(function(btn) {
            if (!btn.dataset.hooked) {
                btn.dataset.hooked = 'true';
                btn.addEventListener('click', function() {
                    if (isAutoEnabled && autoScrollOnDownvote) {
                        setTimeout(goToNext, 150);
                    }
                });
            }
        });
        const sponsorOverlay = document.querySelector('.ytp-sponsor-overlay, .sponsor-segment');
        if (sponsorOverlay) {
            goToNext();
        }
        const video = document.querySelector('video.video-stream');
        if (video && !video.dataset.hooked) {
            video.dataset.hooked = 'true';
            video.addEventListener('ended', function() {
                if (isAutoEnabled) goToNext();
            });
            video.addEventListener('timeupdate', function() {
                if (video.currentTime > 0 && video.duration && video.currentTime >= video.duration - 0.2) {
                    if (isAutoEnabled) goToNext();
                }
            });
        }
    });
    observer.observe(document.body, { childList: true, subtree: true });
    const shareObserver = new MutationObserver(function() {
        const input = document.querySelector('#share-url');
        if (input && input.value && input.value.includes('si=')) {
            input.value = input.value.split('?')[0];
        }
    });
    shareObserver.observe(document.body, { childList: true, subtree: true });
    updatePill();
})();