Skip to content

Commit 10c1be4

Browse files
committed
新增 [自动屏蔽阅读权限 255 的帖子] 功能
1 parent 896a16c commit 10c1be4

1 file changed

Lines changed: 27 additions & 5 deletions

File tree

Hostloc-Enhanced.user.js

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// ==UserScript==
22
// @name 全球主机交流论坛增强
3-
// @version 1.0.8
3+
// @version 1.0.9
44
// @author X.I.U
5-
// @description 自动无缝翻页、自动显示帖子内隐藏回复、回到顶部(右键点击两侧空白处)
5+
// @description 自动无缝翻页、自动显示帖子内隐藏回复、自动屏蔽阅读权限 255 的帖子、回到顶部(右键点击两侧空白处)
66
// @match *://hostloc.com/*
77
// @icon https://www.hostloc.com/favicon.ico
88
// @grant GM_xmlhttpRequest
@@ -21,6 +21,7 @@
2121
var menu_ALL = [
2222
['menu_thread_pageLoading', '帖子内自动翻页', '帖子内自动翻页', true],
2323
['menu_showhide', '自动显示隐藏回复', '自动显示隐藏回复', true],
24+
['menu_delate255', '自动屏蔽阅读权限 255 的帖子', '自动屏蔽阅读权限 255 的帖子', true],
2425
['menu_backToTop', '回到顶部(右键点击两侧空白处)', '回到顶部', true]
2526
], menu_ID = [];
2627
for (let i=0;i<menu_ALL.length;i++){ // 如果读取到的值为 null 就写入默认值
@@ -124,6 +125,7 @@
124125
}else if (patt_forum.test(location.pathname) || location.search.indexOf('mod=forumdisplay') > -1){
125126
// 各板块帖子列表
126127
curSite = DBSite.forum;
128+
if (menu_value('menu_delate255')) delate255(); // 屏蔽阅读权限 255 的帖子
127129
}else if (patt_guide.test(location.search)){
128130
// 导读帖子列表
129131
curSite = DBSite.guide;
@@ -143,12 +145,19 @@
143145
windowScroll(function (direction, e) {
144146
if (direction === "down") { // 下滑才准备翻页
145147
let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
146-
let scrollDelta = 766;
147-
if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) {
148+
if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + 999) {
148149
if (curSite.SiteTypeID === SiteType.FORUM) { // 如果是各版块帖子列表则直接点下一页就行了
149150
let autopbn = document.querySelector('#autopbn');
150-
if (autopbn && autopbn.innerText == "下一页 »"){ // 如果已经在加载中了,就忽略
151+
if (autopbn && autopbn.innerText === "下一页 »"){ // 如果已经在加载中了,就忽略
151152
autopbn.click();
153+
if (menu_value('menu_delate255')) {
154+
let timer = setInterval(function(){
155+
if (document.querySelector('#autopbn').innerText === "下一页 »") {
156+
delate255();
157+
clearInterval(timer);
158+
}
159+
}, 10);
160+
}
152161
}
153162
}else{
154163
ShowPager.loadMorePage();
@@ -190,6 +199,19 @@
190199
}
191200

192201

202+
// 屏蔽阅读权限 255 的帖子
203+
function delate255() {
204+
if (patt_forum.test(location.pathname) || location.search.indexOf('mod=forumdisplay') > -1){
205+
let tbody = document.querySelectorAll('tbody[id^="normalthread_"] .common .xw1');
206+
Array.from(tbody).forEach(function (_this) {
207+
if (_this.innerText === '255') {
208+
_this.parentNode.parentNode.parentNode.remove();
209+
}
210+
})
211+
}
212+
}
213+
214+
193215
// 滚动条事件
194216
function windowScroll(fn1) {
195217
var beforeScrollTop = document.documentElement.scrollTop,

0 commit comments

Comments
 (0)