問題背景
不知道是我裝插件的原因,還是其他啥原因,我現在從首頁打開每一個視頻都有下面的彈窗,彈出一個成為大會員解鎖所有清晰度
的彈窗,同時還暫停了播放
想干的事和解決的辦法
這太影響觀感了,就想着把彈窗去掉,播放不斷片,辦法就是自己寫一個油猴腳本
來屏蔽,腳本代碼如下。最上面的注釋別刪,里面指定了在哪個網站執行該腳本,更多信息見 自己編寫油猴腳本時踩得坑
// ==UserScript==
// @name 屏蔽B站的成為大會員解鎖所有清晰度
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author 至渝
// @match https://www.bilibili.com/video/*
// @grant unsafeWindow
// ==/UserScript==
(function() {
'use strict';
// Your code here...
// 去掉大會員彈窗
var play11=document.querySelector(".bilibili-player-video-state");
console.log(play11);
const style = document.createElement("style");
style.innerHTML = `.bili-dialog-m {display: none !important;}`;
document.head.appendChild(style);
//播放視頻
var timer = setInterval(xunhuan, 100);
var jishu=0
function xunhuan(){
if (document.querySelector(".video-state-pause")!=null){
play11.click();
console.log(play11);
}else{
jishu++;
//如果連續播放了5秒就清除,不清除的話會出現無法暫停視頻
if(jishu>50){ clearInterval(timer);}
}
}
})();
前后對比效果
屏蔽之前
屏蔽之后