Skip to content

Instantly share code, notes, and snippets.

@a358003542
Last active February 20, 2025 11:30
Show Gist options
  • Save a358003542/375ab02166b26542faa9b5e409592c98 to your computer and use it in GitHub Desktop.
Save a358003542/375ab02166b26542faa9b5e409592c98 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name bilibili清爽计划
// @namespace http://tampermonkey.net/
// @version 2025-02-20
// @description try to take over the world!
// @author wander
// @match https://www.bilibili.com/video/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
function remove_comment() {
// 获取要删除的元素
const element = document.getElementById('commentapp');
if (element) {
console.log(`found ${element}`);
element.style.display = "none";
}else{
console.log('can not found commentapp.');
}
}
function remove_ad(){
const element = document.getElementById('slide_ad');
if (element) {
console.log(`found ${element}`);
element.style.display = "none";
}else{
console.log('can not found slide_ad.');
}
}
function remove_rec_list(){
const rec_list = document.getElementsByClassName('video-page-card-small');
for (let i = 0; i < rec_list.length; i++) {
if (i>2){
rec_list[i].style.display = "none";
}
}
}
function remove_more_ad(){
// 使用 querySelectorAll 结合属性选择器选取 class 名包含 ad 的元素
const adElements = document.querySelectorAll('[class*="ad"]');
adElements.forEach((element) => {
element.style.display = "none";
});
}
function delay_deleteElement(){
setTimeout(function () {
remove_comment();
remove_ad();
remove_rec_list();
remove_more_ad();
}, 1000);
}
window.onload = function () {
delay_deleteElement();
}
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment