Skip to content

Commit 6a1181d

Browse files
committed
新增 可选 [帖子内] 是否开启自动翻页。 优化 自动回复方式。 修复 正常回复帖子也会自动回复的问题。
1 parent cef0213 commit 6a1181d

1 file changed

Lines changed: 20 additions & 39 deletions

File tree

3dm-Enhanced.user.js

Lines changed: 20 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// ==UserScript==
22
// @name 3DM论坛增强
3-
// @version 1.0.1
3+
// @version 1.0.2
44
// @author X.I.U
5-
// @description 自动回复、自动无缝翻页、清理置顶帖子
5+
// @description 自动回复、自动无缝翻页、自动清理置顶帖子等
66
// @match *://bbs.3dmgame.com/*
77
// @icon https://bbs.3dmgame.com/favicon.ico
88
// @grant GM_xmlhttpRequest
@@ -12,6 +12,9 @@
1212
// ==/UserScript==
1313

1414
(function() {
15+
// 是否开启帖子内自动翻页功能,true 为开启,false 为关闭。
16+
var thread_pageLoading = false;
17+
1518
// 随机回复帖子的内容
1619
var replyList = [
1720
"感谢楼主分享!",
@@ -70,14 +73,14 @@
7073
patt_forum = /\/forum-\d+-\d+\.html/,
7174
patt_forum_2 = /mod\=forumdisplay/,
7275
patt_guide = /mod\=guide\&view\=(hot|digest)/,
73-
patt_reply = /mod\=post&action\=reply/
76+
patt_reply = /mod\=post&action\=reply/,
77+
patt_reply_2 = /extra\=page\%3D1&page\=/
7478

7579
// URL 判断
7680
if (patt_thread.test(location.pathname) || patt_thread_2.test(location.search)){
7781
// 帖子内
78-
curSite = DBSite.thread;
79-
backReply(); // 先判断是否刚刚在回复帖子,如果是则返回第一页
80-
autoReply(); // 如果有隐藏内容,则自动点击回复
82+
if(thread_pageLoading)curSite = DBSite.thread;
83+
autoReply(); // 如果有隐藏内容,则自动回复
8184
pageLoading(); // 自动翻页
8285
}else if (patt_forum.test(location.pathname) || patt_forum_2.test(location.search)){
8386
// 各板块帖子列表
@@ -88,9 +91,6 @@
8891
// 导读帖子列表
8992
curSite = DBSite.guide;
9093
pageLoading(); // 自动翻页
91-
}else if (patt_reply.test(location.search)){
92-
// 帖子回复页面
93-
writeReply(); // 写入自动回复内容
9494
}
9595

9696

@@ -130,47 +130,28 @@
130130
}
131131

132132

133-
// 自动点击回复
133+
// 自动回复
134134
function autoReply(){
135135
if (loginStatus == true){
136-
// 存在隐藏内容,则点击回复按钮
136+
// 存在隐藏内容,则自动回复
137137
var autoreply = document.querySelector('.locked a');
138138
if (autoreply){
139-
autoreply.click();
139+
writeReply();
140+
setTimeout(`window.scrollTo(0,0)`, 1000);
140141
}
141142
}
142143

143144
}
144145

145146

146-
// 写入回复内容
147+
// 写入自动回复内容
147148
function writeReply(){
148-
if (loginStatus == true){
149-
document.getElementById('e_iframe').contentWindow.document.querySelector('body').innerHTML = replyList[Math.floor((Math.random()*replyList.length))];
150-
document.getElementById('postsubmit').click();
151-
}
152-
153-
}
154-
155-
156-
// 回复后返回帖子第一页
157-
function backReply(){
158-
if (loginStatus == true){
159-
// 判断前一个页面是否是回复帖子页面
160-
if (document.referrer){
161-
if (patt_reply.test(document.referrer)){
162-
// 判断上一页按钮是否存在,如果存在则代表不是帖子第一页
163-
if (document.querySelector('.prev')){
164-
// 寻找第一页按钮并点击
165-
var firstPage = document.querySelector('.pg a');
166-
if (firstPage.innerHTML == "1 ..."){
167-
firstPage.click();
168-
}
169-
}else{
170-
// 如果不存在,说明是帖子第一页,则返回顶部
171-
window.scrollTo('0','0');
172-
}
173-
}
149+
var textarea = document.getElementById("fastpostmessage");
150+
if (textarea){
151+
textarea.value = textarea.value + replyList[Math.floor((Math.random()*replyList.length))];
152+
var fastpostsubmit = document.getElementById("fastpostsubmit");
153+
if (fastpostsubmit){
154+
fastpostsubmit.click();
174155
}
175156
}
176157
}

0 commit comments

Comments
 (0)