本帖最后由 千城忆梦 于 2022-10-19 23:22 编辑
先放代码,代码简介在最后:
[JavaScript] 纯文本查看 复制代码 // ==UserScript==
// @name 动漫花园净化(首页+)
// @namespace Violentmonkey Scripts
// @match https://share.dmhy.org/
// @match https://share.dmhy.org/topics/list/page/*
// @grant none
// @version 1.0
// @AuThor RoachLin
// @description 2022/9/30 00:00:00
// ==/UserScript==
(function() {
//浏览器使用uBlock Origin插件实现去广告功能
//右上角链接
var a = document.getElementsByClassName("links");
var b = a[0].firstElementChild;
for (var i = 1; i <= 7; ++i) {
b.nextElementSibling.remove();
}
//右上角“联盟+”
document.getElementById("expand-button").remove();
//顶部“新番资源索引”栏
document.getElementById("mini_jmd").remove();
//表格上方“张贴分享”+滚动文字
var a = document.getElementsByClassName("clear");
a[1].remove();
//表格内部顶栏左边
var a = document.getElementsByClassName("fl");
for (var i = a.length - 1; i >= 0; --i) {
a[i].remove();
}
//表格内部顶栏右边
var a = document.getElementsByClassName("fr");
a[0].firstElementChild.remove();
a[0].firstElementChild.remove();
//表头“磁鏈”
var a = document.getElementsByClassName("{sorter: false}");
for (var i = a.length - 1; i >= 0; --i) {
a[i].remove();
}
//表头“種子”
var a = document.getElementsByClassName("{sorter: 'digit', sortInitialOrder: 'desc'} header");
for (var i = a.length - 1; i >= 0; --i) {
a[i].remove();
}
//表头“下載”
var a = document.getElementsByClassName("{sorter: 'digit', sortInitialOrder: 'desc'} header");
for (var i = a.length - 1; i >= 0; --i) {
a[i].remove();
}
//表头“完成”
var a = document.getElementsByClassName("{sorter: 'digit', sortInitialOrder: 'desc'} header");
for (var i = a.length - 1; i >= 0; --i) {
a[i].remove();
}
//表项“磁鏈”
var a = document.getElementsByClassName("download-arrow arrow-magnet");
for (var i = a.length - 1; i >= 0; --i) {
var self = a[i].parentElement;
var parent = self.parentElement;
parent.removeChild(self);
}
//表项“種子”
var a = document.getElementsByClassName("btl_1");
for (var i = a.length - 1; i >= 0; --i) {
var self = a[i].parentElement;
var parent = self.parentElement;
parent.removeChild(self);
}
//表项“下載”
var a = document.getElementsByClassName("bts_1");
for (var i = a.length - 1; i >= 0; --i) {
var self = a[i].parentElement;
var parent = self.parentElement;
parent.removeChild(self);
}
//表格背景色变蓝
var a = document.querySelectorAll("tr.odd");
for (var i = 0; i < a.length; ++i) {
a[i].className = "even";
}
//表项“完成”
var a = document.querySelectorAll("tr.even");
for (var i = a.length - 1; i >= 0; --i) {
var self = a[i].lastElementChild.previousElementSibling;
var parent = self.parentElement;
parent.removeChild(self);
}
//底部“善意提醒”和“重要聲明”
var a = document.getElementsByClassName("table");
a[1].remove();
a[1].remove();
//底部信息
var a = document.getElementById("1280_ad");
a.lastElementChild.remove();
a.lastElementChild.remove();
a.lastElementChild.remove();
})();
[JavaScript] 纯文本查看 复制代码 // ==UserScript==
// @name 动漫花园净化(资源详情页)
// @namespace Violentmonkey Scripts
// @match https://share.dmhy.org/topics/view/*_.html
// @grant none
// @version 1.0
// @author RoachLin
// @description 2022/9/30 00:00:00
// ==/UserScript==
(function() {
//浏览器使用uBlock Origin插件实现去广告功能
//右上角链接
var a = document.getElementsByClassName("links");
var b = a[0].firstElementChild;
for (var i = 1; i <= 7; ++i) {
b.nextElementSibling.remove();
}
//右上角“联盟+”
document.getElementById("expand-button").remove();
//顶部“新番资源索引”栏
document.getElementById("mini_jmd").remove();
//主体上方“张贴分享”+滚动文字
var a = document.getElementsByClassName("clear");
a[1].remove();
//左侧“熱門資源”
var a = document.getElementsByClassName("topics_cult box ui-corner-all nocontent");
for (var i = a.length - 1; i >= 0; --i) {
a[i].remove();
}
var a = document.getElementsByClassName("user-sidebar");
a[0].lastElementChild.remove();
//主体右上角“種子下載”、“在线播放”、“訪客互動”和“另類分享”
var a = document.getElementsByClassName("info resource-info right");
var b = a[0].firstElementChild;
b.lastElementChild.remove();
b.lastElementChild.remove();
b.lastElementChild.previousElementSibling.remove();
b.lastElementChild.previousElementSibling.remove();
//主体右上角信息列移动位置
document.styleSheets[0].rules[190].style.cssText = "margin-top: 0px;";
document.styleSheets[0].rules[192].style.cssText = "float: center;";
//“簡介: ”
var a = document.getElementsByClassName("topic-nfo box ui-corner-all");
a[0].firstElementChild.remove();
a[0].firstElementChild.remove();
a[0].lastElementChild.remove();
//“BT列表”
var a = document.getElementsByClassName("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");
for (var i = a.length - 1; i >= 0; --i) {
a[i].remove();
}
//“會員專用連接”上方空白
document.styleSheets[0].rules[619].style.cssText = "padding: 0em 0em; border-width: 0px; background: none;";
//“彈幕播放連接”和“外部搜索連接”
var a = document.getElementById("tabs-1");
a.lastElementChild.previousElementSibling.previousElementSibling.remove();
a.lastElementChild.previousElementSibling.previousElementSibling.remove();
//“***以下發佈所有評論,僅代表網友觀點與本站無關!***”
document.styleSheets[0].rules[234].style.cssText = "display: none";
//“快速發帖”
document.styleSheets[0].rules[227].style.cssText = "display: none";
//评论框右边“注意:”
document.styleSheets[0].rules[228].style.cssText = "display: none";
//底部信息
var a = document.getElementById("1280_ad");
a.lastElementChild.remove();
a.lastElementChild.remove();
a.lastElementChild.remove();
})();
[JavaScript] 纯文本查看 复制代码 // ==UserScript==
// @name 动漫花园屏蔽指定项(首页+)
// @namespace Violentmonkey Scripts
// @match https://share.dmhy.org/
// @match https://share.dmhy.org/topics/list/page/*
// @grant none
// @version 1.0
// @author RoachLin
// @description 2022/9/30 00:00:00
// ==/UserScript==
(function() {
//屏蔽指定分类
//3:漫畫
//6:日劇
//12:特攝
//var sorts = [3, 6, 12];
var sorts = [111, 222, 333];
var a = document.querySelectorAll("a[href]");
for (var i = 0; i < a.length; ++i) {
for (var j = 0; j < sorts.length; ++j) {
if (a[i].href == "https://share.dmhy.org/topics/list/sort_id/" + sorts[j] && a[i].title == "") {
a[i].parentElement.parentElement.remove();
}
}
}
//屏蔽指定字幕组
var teams = [1111, 2222, 3333];
var a = document.querySelectorAll("a[href]");
for (var i = 0; i < a.length; ++i) {
for (var j = 0; j < teams.length; ++j) {
if (a[i].href == "https://share.dmhy.org/topics/list/team_id/" + teams[j]) {
a[i].parentElement.parentElement.parentElement.remove();
}
}
}
//屏蔽指定用户
var users = [1111111, 2222222, 3333333];
var a = document.querySelectorAll("a[href]");
for (var i = 0; i < a.length; ++i) {
for (var j = 0; j < users.length; ++j) {
if (a[i].href == "https://share.dmhy.org/topics/list/user_id/" + users[j]) {
a[i].parentElement.parentElement.remove();
}
}
}
//屏蔽指定标题内容
var str = ["111", "222"];
var a = document.querySelectorAll("a[href]");
for (var i = 0; i < a.length; ++i) {
for (var j = 0; j < str.length; ++j) {
if (a[i].innerText.includes(str[j])) {
a[i].parentElement.parentElement.remove();
}
}
}
})();
以上是对动漫花园(https://share.dmhy.org/)进行页面净化和屏蔽指定资源的三个脚本。
第一个代码是净化首页,第二个代码是净化资源详情页,第三个代码是在首页屏蔽指定资源。
我在代码中写了清晰的注释,哪部分代码净化了哪部分页面内容,应该很清晰了。
注意,第三个代码,sorts、teams、users、str这四个数组需要填入你自己需要屏蔽的分类id、字幕组id、用户id、部分标题内容。
本人前端苦手,这三个脚本都是用原生html写的(大概?),可能不够简洁,也可能有bug,欢迎评论区交流!
|