Spankbang: Prevent Video Thumbnails From Auto-Play

Get rid of annoying video preview auto-play

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Spankbang: Prevent Video Thumbnails From Auto-Play
// @namespace    http://tampermonkey.net/
// @version      2025-04-10
// @description  Get rid of annoying video preview auto-play
// @author       Anonymous
// @license      Unlicense
// @match        https://spankbang.party/*
// @match        https://spankbang.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=spankbang.com
// @grant        none
// ==/UserScript==

//
// Taken from https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver and adapted
//

// Options for the observer (which mutations to observe)
const config = { attributes: true, childList: true, subtree: true };

// Callback function to execute when mutations are observed
const callback = (mutationList, observer) => {
  for (const mutation of mutationList) {
    if (mutation.type === "childList" && mutation.addedNodes.length > 0) {
        // Search results page

        if (mutation.target.tagName == 'DIV' && mutation.target.classList.contains('video-js') && !mutation.previousSibling) {
            if (mutation.target.parentElement && mutation.target.parentElement.matches(':hover')) {
                // User hovered for a preview. Doing nothing.
            } else {
                // Programmatically triggerered by the site. Disabling.

                try {
                    mutation.target.setAttribute('style', 'display: none');
                    jQuery(mutation.target).parents('.is_rotating').removeClass('is_rotating'); // blinking
                } catch {};
            };
        };
    } else if (mutation.type === "attributes") {
        // Main page & other areas

        //if (mutation.target.tagName == 'VIDEO') try {jQuery('[id^=recommended_video],.js-video-item video').hide()} catch {};

        if (mutation.target.tagName == 'VIDEO' && mutation.attributeName == 'style' && !mutation.target.getAttribute('style') && !mutation.previousSibling) {
             if (mutation.target.parentElement && mutation.target.parentElement.matches(':hover')) {
                // User hovered for a preview. Doing nothing.
            } else {
                // Programmatically triggerered by the site. Disabling.

                try {mutation.target.setAttribute('style', 'display: none')} catch {};
            };
        };
    };
  };
};

// Create an observer instance linked to the callback function
const observer = new MutationObserver(callback);

// Start observing the target node for configured mutations
jQuery(".js-media-list,.video-list").each((_, grid) => {
    //console.log('set observer on', x);
    observer.observe(grid, config);
});