b站大会员广告

b站大会员广告清除

// ==UserScript==
// @name         b站大会员广告
// @namespace    wrongThing
// @version      0.3
// @description  b站大会员广告清除
// @author       wrongThing
// @match        *.bilibili.com/video/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// ==/UserScript==

(function () {
  'use strict';
  var maxCheckTime = 5 * 60 * 60;
  var startTime = +new Date();
  var endTime = startTime + maxCheckTime;
  var timer = null;
  var count = 0;

  var e = document.createEvent("MouseEvents")
  e.initEvent('click', true, true);

  let video = null;
  let isPlaying = false;

  function clearTimer() {
    timer && clearInterval(timer);
    timer = null;
  }
  function controlAd() {
    count++;
    console.log(`【b站大会员弹窗广告检测】:第${count}次检测`)
    if (+new Date() >= endTime) {
      clearTimer();
      console.log(`【b站大会员弹窗广告检测】:超时退出`)
      return;
    }
    const closeButton = document.querySelector('.bili-dialog-m .q1080p .icon.close');
    if (!video) {
       video = document.querySelector('video')
    }
    if (closeButton) {
      // adDialog.parentNode.removeChild(adDialog);
      closeButton.dispatchEvent(e);
      if (isPlaying) {
         video && video.play();
         console.log('恢复播放状态')
      }
      clearTimer();
      console.log(`【b站大会员弹窗广告检测】:成功清除`)
    } else {
      isPlaying = !(video && video.paused);
    }
  }
  timer = setInterval(controlAd, 200)
  // Your code here...
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址