Greasy Fork is available in English.
3DM去广告,隐藏置顶,新页面打开,自动下一页
当前为
// ==UserScript==
// @name 3DM净化
// @namespace http://tampermonkey.net/
// @version 1.00
// @description 3DM去广告,隐藏置顶,新页面打开,自动下一页
// @author You
// @match *://bbs.3dmgame.com/forum*
// @match *://bbs.3dmgame.com/thread*
// @grant none
// ==/UserScript==
(function () {
"use strict";
var run_mk = false;
if (/bbs\.3dmgame\.com\/thread*/.test(location.href)) {
cleanTop();
atarget();
setTimeout(() => autopage(".bm_h"), 500);
} else if (/bbs\.3dmgame\.com\/forum*/.test(location.href)) {
cleanTop();
atarget();
setTimeout(() => autopage('"#autopbn"'), 500);
}
ad();
function ad() {
function subad(path) {
let r = document.querySelectorAll(path);
if (r.length > 0) r.forEach((e) => (e.style.display = "none"));
}
const adlist = [
"#mn_N124d",
"#mn_N9e02",
"#mn_N7990",
"#mn_Nadbb",
"#mn_Na9bb",
"#mn_Na9bb",
"#scbar_hot a",
"#category_437",
"#pid267331864 > tbody:nth-child(1) > tr:nth-child(2) > td:nth-child(1)",
".image",
];
adlist.forEach((e) => subad(e));
}
function hidepage() {
const ele = document.querySelectorAll(
"div.bmw:nth-child(1) > div:nth-child(1) > span:nth-child(1)"
);
if (ele.length > 0) {
ele.forEach((e) => e.click());
}
}
// 清理置顶帖子
function cleanTop() {
const ele = document.querySelectorAll("a.showhide.y");
if (ele.length > 0) {
ele.forEach((e) => e.click());
}
}
function atarget() {
const ele = document.querySelectorAll("#atarget");
if (ele.length > 0) {
ele.forEach((e) => {
if (e.className != "y atarget_1") e.click();
});
}
}
function autopage(divid) {
window.addEventListener(
"scroll",
function () {
const htmlHeight =
document.body.scrollHeight || document.documentElement.scrollHeight;
//clientHeight是网页在浏览器中的可视高度,
const clientHeight =
document.body.clientHeight || document.documentElement.clientHeight;
//scrollTop是浏览器滚动条的top位置,
const scrollTop =
document.body.scrollTop || document.documentElement.scrollTop;
//通过判断滚动条的top位置与可视网页之和与整个网页的高度是否相等来决定是否加载内容;
if (
parseInt(scrollTop) + parseInt(clientHeight) >=
parseInt(htmlHeight)
) {
run_mk = true;
checkele(divid);
run_mk = false;
}
},
false
);
}
/**
* @description : 根据ID检查元素是否可见,再点击
* @param {*} cssid
* @return {*}
*/
function checkele(cssid) {
function checkVisible(elm) {
var rect = elm.getBoundingClientRect();
var viewHeight = Math.max(
document.documentElement.clientHeight,
window.innerHeight
);
return !(rect.bottom < 0 || rect.top - viewHeight >= 0);
}
const s = document.querySelector(cssid);
if (s) {
let r = checkVisible(s);
if (r) {
s.click();
// serch();
}
}
}
})();