Sleazy Fork is available in English.

AV_AD_Block

missav

// ==UserScript==
// @name         AV_AD_Block
// @description  missav
// @icon         https://static.missav.com/img/favicon.png
// @namespace    loadingi.local
// @version      2.0
// @author       ch
// @match        https://missav.com/*
// @grant        GM_setValue
// @grant        GM_getValue
// --有 bug grant        GM_xmlhttpRequest
// @license      GPL-3.0-only
// ==/UserScript==

(function() {
    'use strict';
////missav.com
    //  进度按钮背景
    let proc_ctls = document.getElementsByClassName('isolate inline-flex rounded-md shadow-sm');
    for (let i = 0; i < proc_ctls.length; i++) {
        proc_ctls[i].style.backgroundColor = "#222";
}
    //  强制显示 进度控制按钮
    let  proc_btn = document.getElementsByClassName('sm\:hidden')[0];
    if (proc_btn){
        proc_btn.style.display = "flex";
    }

    // 进度控制 节点
    var ctlNode = document.getElementsByClassName('sm:hidden flex justify-between -mx-4 px-3 pt-3 pb-1 bg-black')[0];
    // 检查该节点是否存在
    if (ctlNode) {
        // 获取该节点内所有button元素
        var buttons = ctlNode.getElementsByTagName('button');
        // 遍历所有button元素,设置它们的边框样式为'none'
        for (var i = 0; i < buttons.length; i++) {
            buttons[i].style.color = "burlywood";
            buttons[i].style.boxShadow = "none";
        }
    }
    //  Loop按钮边框
    let  loop_btn = document.getElementsByClassName('sm:ml-6')[0].getElementsByTagName('button')[0];
    if (loop_btn){
        // loop_btn.style.borderColor = "blueviolet";
        loop_btn.style.borderWidth = "0px";
        // loop_btn.classList.remove('border');
    }

    

    //  Loop按钮边框
    let  logo_field = document.getElementsByClassName('font-serif')[0];
    logo_field.remove();

    // 展开详情
    let info_text= document.getElementsByClassName('mb-1 text-secondary break-all line-clamp-2')[0];
    info_text.showMore = true;

// -----------------------------------------------------------------------------------------------------------------
    //  窗口失焦 暂停播放 
    let elements = document.getElementsByClassName('aspect-w-16 aspect-h-9');
    let tagetElement = elements[11];
    tagetElement.removeAttribute('@click');
    tagetElement.removeAttribute('@keyup.space.window')

    // 设置背景为纯黑,iPhone  safari 顶部和底部将统一为黑色
    document.body.style.backgroundColor = "black";
  //Block Player OnceClick PopUp
    if(document.querySelector("div.flex-1.order-first")){
        var elem0 = document.querySelector("div.flex-1.order-first").children[0]
        elem0.removeAttribute('x-init')
        elem0.removeAttribute('x-data')
    }
    if(document.querySelector("div.relative.-mx-4.-mt-6.sm\\:m-0")){
        var elem1 = document.querySelector("div.relative.-mx-4.-mt-6.sm\\:m-0").children[0]
        elem1.removeAttribute(elem1.attributes[0].name)
        elem1.removeAttribute('@click.once')
    }

  //Block GIF AD
    function blockgif(){    
        
        var elmt1 = document.querySelector("link[href*='app.1aad5686.js']") //关键 js
        var elmt2 = document.querySelector("script[src*='app.1aad5686.js']") //关键 js
        var elmt3 = document.querySelector('div[class^="fixed right-2 bottom-2"')  // 似乎未生效
        var elmt4 = document.querySelector("script[src*='inpage.push.js']") // 推送iframe 的 js
        var elmt5 = document.querySelector("script[src*='hartattenuate.com']") // 可疑的 js
        var elmt6 = document.querySelector('div.under_player')   // 播放器底部广告
        var elmt7 = document.querySelector('div.space-y-5.mb-5') //页面底部广告
        var elmt8 = document.getElementsByClassName('space-y-2 mb-4 ml-4 list-disc text-nord14')[0] //详情文字广告

        for (var i = 1; i<=8; i++){
            var obj = eval('elmt'+i)
            console.log("Try elmt"+i)
            if(obj){
                obj.remove();
                console.log('Detection! Removed -------- elmt'+i);
            }else{continue}
        }
        //iframe blk 屏蔽所有 iframe 
        // document.querySelectorAll("iframe").forEach(i => i.setAttribute('style','display:none'))
        document.querySelectorAll("iframe").forEach(i => {
            i.remove();
            console.log('Detection! Removed -------- iframe');
          });
        
    }
  //Block Video AD
    function blockvideoad(){
        var elem004 = document.querySelector('div[class^="rootContent--"]')
        console.log('trying')
        if(elem004){
            console.log('Detection! Removed -------- rootContent--');
            elem004.parentElement.remove();
            //清除计时器
            //clearInterval (timerVar);
            //timerVar= "";
        }
    }
  //Block script
    function blockScript(){
        var anchors = document.querySelectorAll("script");
        for(var i=0;i<anchors.length;i++){
            if(anchors[i].innerText.indexOf("htmlAds")>0){
                console.log("Detection! Removed -------- htmlAds")
                anchors[i].remove()
                break;
            }else{console.log("noMatch")}
        }
    }
  //LOOP
    var timerVar = setInterval (function() {blockProcc(); }, 50);
    var hits = 100
    function blockProcc(){
        //console.log('trying')
        blockgif();
        blockScript();
        blockvideoad();
        hits--
        console.log(hits)
        if(hits<=0){clearInterval (timerVar);console.log('exited');}
    }


    // 创建按钮元素
    var button = document.createElement("button");
    button.innerText = "点击我";
    button.style.position = "fixed";
    button.style.bottom = "20px";
    button.style.right = "20px";
    button.style.transform = "translate(-50%, -50%)";
    button.style.zIndex = "1000";
    button.style.padding = ".375rem .625rem";
    button.style.backgroundColor = "#222";
    button.style.borderRadius = "10px";
    button.style.color = "burlywood";
    button.style.borderWidth = "1px";



    // 定义点击事件处理程序
    function handleClick() {
        // 获取目标<div>元素
        var targetDiv = document.getElementsByClassName('flex-1 order-first')[0];

        // 创建新的<div>元素
        var newDiv = document.createElement('div');

        // 设置新<div>元素的样式
        newDiv.style.backgroundColor = 'black';
        newDiv.style.opacity = '0.9';
        newDiv.style.position = 'absolute';
        newDiv.style.top = '0';
        newDiv.style.left = '0';
        newDiv.style.width = '100%';
        newDiv.style.height = '100%';
        newDiv.style.zIndex = '299998';

        // 将新节点插入到目标节点的后面
        targetDiv.parentNode.insertBefore(newDiv, targetDiv.nextSibling);

        var screenWidth = window.innerWidth;
        var Video_node = targetDiv.getElementsByTagName('div')[0]
        Video_node.style.position = 'fixed';
        Video_node.style.zIndex = '300000';
        Video_node.style.left = '10px';
        Video_node.style.right = '10px';
        Video_node.style.top = '30%';
    }

    // 将点击事件处理程序绑定到按钮
    button.addEventListener("click", handleClick);

    // 将按钮添加到页面的主体中
    document.body.appendChild(button);



})();