Skip to content

Commit 9abe414

Browse files
committed
新增 [回到顶部](右键点击两侧空白处)功能; 新增 [自动回复、自动无缝翻页、清理置顶帖子] 脚本菜单开关
1 parent 01216ea commit 9abe414

1 file changed

Lines changed: 56 additions & 37 deletions

File tree

Zhiyoo-Enhanced.user.js

Lines changed: 56 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// ==UserScript==
22
// @name 智友邦论坛增强
3-
// @version 1.1.7
3+
// @version 1.1.8
44
// @author X.I.U
5-
// @description 自动签到、自动回复、自动无缝翻页、清理置顶帖子、简化附件兑换/下载、清理帖子标题〖XXX〗【XXX】文字
5+
// @description 自动签到、自动回复、自动无缝翻页、回到顶部(右键点击两侧空白处)、清理置顶帖子、简化附件兑换/下载、清理帖子标题〖XXX〗【XXX】文字
66
// @icon http://bbs.zhiyoo.net/favicon.ico
77
// @match *://bbs.zhiyoo.net/*
88
// @match *://www.zhiyoo.net/search.php*
@@ -20,6 +20,10 @@
2020

2121
(function() {
2222
var menu_ALL = [
23+
['menu_autoReply', '自动回复', '自动回复', true],
24+
['menu_pageLoading', '自动无缝翻页', '自动无缝翻页', true],
25+
['menu_backToTop', '回到顶部(右键点击两侧空白处)', '回到顶部', true],
26+
['menu_cleanTopPost', '清理置顶帖子', '清理置顶帖子', true],
2327
['menu_cleanPostTitle', '清理帖子标题开头〖〗【】文字', '清理帖子标题开头〖〗【】文字', true],
2428
['menu_qianDaoRedirectURL', '当前页面设为签到后重定向地址', '已设置当前页面为签到后重定向地址', 'http://bbs.zhiyoo.net/forum.php?mod=forumdisplay&fid=42&filter=author&orderby=dateline']
2529
], menu_ID = [];
@@ -166,6 +170,7 @@
166170
pageLoading(); // 自动无缝翻页
167171
break;
168172
}
173+
backToTop(); // 回到顶部(右键点击两侧空白处)
169174
}else if(location.pathname === '/search.php'){
170175
curSite = DBSite.search; // 搜索结果列表页(自动翻页)
171176
pageLoading(); // 自动无缝翻页
@@ -184,29 +189,13 @@
184189
}
185190

186191

187-
// 自动翻页
188-
function pageLoading() {
189-
if (curSite.SiteTypeID > 0){
190-
windowScroll(function (direction, e) {
191-
if (direction === "down") { // 下滑才准备翻页
192-
let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
193-
let scrollDelta = 666;
194-
if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) {
195-
ShowPager.loadMorePage();
196-
}
197-
}
198-
});
199-
}
200-
}
201-
202-
203192
// 自动签到
204193
function qiandao(){
205194
if (loginStatus){
206-
if(document.getElementById("yl"))
195+
if(document.getElementById('yl'))
207196
{
208-
document.querySelector('#yl').click();
209-
document.querySelector('.tr3.tac div a').click();
197+
document.getElementById('yl').click();
198+
document.querySelector('td.tr3.tac div a').click();
210199
}
211200
setTimeout(location.href=menu_value('menu_qianDaoRedirectURL'), 2000); // 跳转到指定URL
212201
}
@@ -215,6 +204,7 @@
215204

216205
// 自动回复
217206
function autoReply(){
207+
if (!menu_value('menu_autoReply')) return
218208
if (loginStatus){
219209
// 存在隐藏内容,自动回复
220210
if (document.getElementsByClassName("showhide").length == 0){
@@ -262,6 +252,45 @@
262252
}
263253

264254

255+
// 自动无缝翻页
256+
function pageLoading() {
257+
if (!menu_value('menu_pageLoading')) return
258+
if (curSite.SiteTypeID > 0){
259+
windowScroll(function (direction, e) {
260+
if (direction === "down") { // 下滑才准备翻页
261+
let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
262+
let scrollDelta = 666;
263+
if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) {
264+
ShowPager.loadMorePage();
265+
}
266+
}
267+
});
268+
}
269+
}
270+
271+
272+
// 回到顶部(右键点击空白处)
273+
function backToTop() {
274+
if (!menu_value('menu_backToTop')) return
275+
document.getElementById("nv_forum").oncontextmenu = function(event){
276+
if (event.target==this) {
277+
event.preventDefault();
278+
window.scrollTo(0,0)
279+
}
280+
}
281+
}
282+
283+
284+
// 清理置顶帖子
285+
function cleanTop(){
286+
if (!menu_value('menu_cleanTopPost')) return
287+
let showhide = document.querySelectorAll("a.showhide.y");
288+
if (showhide.length > 0){
289+
showhide.forEach(el=>el.click());
290+
}
291+
}
292+
293+
265294
// 兑换附件后立即返回
266295
function attachmentBack() {
267296
let attachmentback = document.querySelector('#messagetext p.alert_btnleft a');
@@ -295,24 +324,14 @@
295324
}
296325

297326

298-
// 清理置顶帖子
299-
function cleanTop(){
300-
let showhide = document.querySelectorAll("a.showhide.y");
301-
if (showhide.length > 0){
302-
showhide.forEach(el=>el.click());
303-
}
304-
}
305-
306-
307327
// 清理帖子列表中帖子标题开头的〖XXX〗【XXX】文字
308328
function cleanPostTitle(){
309-
if (menu_value('menu_cleanPostTitle')){
310-
let cleanposttitle = document.querySelectorAll("a.s.xst");
311-
if (cleanposttitle.length > 0){
312-
for(let num = postNum;num<cleanposttitle.length;num++){
313-
cleanposttitle[num].innerText = cleanposttitle[num].innerText.replace(patt_posttitle, ``);
314-
postNum += 1;
315-
}
329+
if (!menu_value('menu_cleanPostTitle')) return
330+
let cleanposttitle = document.querySelectorAll("a.s.xst");
331+
if (cleanposttitle.length > 0){
332+
for(let num = postNum;num<cleanposttitle.length;num++){
333+
cleanposttitle[num].innerText = cleanposttitle[num].innerText.replace(patt_posttitle, ``);
334+
postNum += 1;
316335
}
317336
}
318337
}

0 commit comments

Comments
 (0)