Spankbang: Prevent Video Thumbnails From Auto-Play

Get rid of annoying video preview auto-play

目前為 2025-04-10 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
});