Sleazy Fork is available in English.

Rule34 enhance

no ad

// ==UserScript==
// @name         Rule34 enhance
// @namespace    http://tampermonkey.net/
// @version      20240531
// @description  no ad
// @author       You
// @match        https://rule34.xxx/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=rule34.xxx
// @grant        none
// @license      MIT
// ==/UserScript==
// 油猴修改样式专用版$Q
function $Q(selector) {
    let ele = document.querySelector(selector);
    if (ele == null)
    {
        return {style: {}};
    }
    else
    {
       return ele;
    }
}

function $QALL(query) {
    return document.querySelectorAll(query);
}

function DisplayNone(queryArr)
{
    for (const query of queryArr)
    {
        $Q(query).style.display = "none";
    }
}

function Hidden(queryArr)
{
    for (const query of queryArr)
    {
        $Q(query).style.visibility = "hidden";
    }
}

function UntilDone(fnBool, delay) {
    setTimeout(function() {
            if (!fnBool()) {
                UntilDone(fnBool, delay);
            }}, delay);
}


(function() {
    'use strict';
    $QALL("#post-list > div.content > div.image-list > span > a").forEach(item => {item.taget = "_blank"});

    DisplayNone(["#post-list > div.content > div:nth-child(7)" /* 去搜索页广告 */ ]);


    // =================
    // === 去视频广告部分
    // ================
    let videoSrc = $Q("#gelcomVideoPlayer > source").src;

    if (videoSrc == "") {
        UntilDone(function() {
            videoSrc = $Q("#gelcomVideoPlayer > source").src;
            return videoSrc != "";
        }, 200);
    }

    let videoTime = 0;
    setInterval(function(){
        let videoEle = $Q("#gelcomVideoPlayer");

         videoEle.style.height = `${window.innerHeight - 30}px`;


        if (videoEle.src != videoSrc && videoEle.src != "") {
            videoEle.src = videoSrc;
            videoEle.play();

            videoEle.currentTime = videoTime;
        } else {
           videoTime = videoEle.currentTime
        }

        // 去视频广告
        DisplayNone(["#vast_clickthrough_layer_gelcomVideoPlayer"/* 点击广告跳转 */,
                     "#gelcomVideoPlayer_fluid_cta" /*点击跳转*/ ,
                     "#skip_button_gelcomVideoPlayer" /*还剩几秒*/]);




        // 去小广告
        // DisplayNone(["#post-view > div.sidebar > span > div > div" /*左边*/,
        //             "#fit-to-screen > div.flexi > div.sidebarRight.verticalFlexWithMargins" /*右上*/,
        //             "#click-wrapper" /* 右下 */,
        //             "#fit-to-screen > div.flexi > div.sidebarRight.verticalFlexWithMargins > div:nth-child(5) > div" /*右下下*/
        //            ]);

    }, 500);

    
})();