|
1 | 1 | // ==UserScript== |
2 | 2 | // @name 3DM论坛增强 |
3 | | -// @version 1.0.1 |
| 3 | +// @version 1.0.2 |
4 | 4 | // @author X.I.U |
5 | | -// @description 自动回复、自动无缝翻页、清理置顶帖子 |
| 5 | +// @description 自动回复、自动无缝翻页、自动清理置顶帖子等 |
6 | 6 | // @match *://bbs.3dmgame.com/* |
7 | 7 | // @icon https://bbs.3dmgame.com/favicon.ico |
8 | 8 | // @grant GM_xmlhttpRequest |
|
12 | 12 | // ==/UserScript== |
13 | 13 |
|
14 | 14 | (function() { |
| 15 | + // 是否开启帖子内自动翻页功能,true 为开启,false 为关闭。 |
| 16 | + var thread_pageLoading = false; |
| 17 | + |
15 | 18 | // 随机回复帖子的内容 |
16 | 19 | var replyList = [ |
17 | 20 | "感谢楼主分享!", |
|
70 | 73 | patt_forum = /\/forum-\d+-\d+\.html/, |
71 | 74 | patt_forum_2 = /mod\=forumdisplay/, |
72 | 75 | 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\=/ |
74 | 78 |
|
75 | 79 | // URL 判断 |
76 | 80 | if (patt_thread.test(location.pathname) || patt_thread_2.test(location.search)){ |
77 | 81 | // 帖子内 |
78 | | - curSite = DBSite.thread; |
79 | | - backReply(); // 先判断是否刚刚在回复帖子,如果是则返回第一页 |
80 | | - autoReply(); // 如果有隐藏内容,则自动点击回复 |
| 82 | + if(thread_pageLoading)curSite = DBSite.thread; |
| 83 | + autoReply(); // 如果有隐藏内容,则自动回复 |
81 | 84 | pageLoading(); // 自动翻页 |
82 | 85 | }else if (patt_forum.test(location.pathname) || patt_forum_2.test(location.search)){ |
83 | 86 | // 各板块帖子列表 |
|
88 | 91 | // 导读帖子列表 |
89 | 92 | curSite = DBSite.guide; |
90 | 93 | pageLoading(); // 自动翻页 |
91 | | - }else if (patt_reply.test(location.search)){ |
92 | | - // 帖子回复页面 |
93 | | - writeReply(); // 写入自动回复内容 |
94 | 94 | } |
95 | 95 |
|
96 | 96 |
|
|
130 | 130 | } |
131 | 131 |
|
132 | 132 |
|
133 | | - // 自动点击回复 |
| 133 | + // 自动回复 |
134 | 134 | function autoReply(){ |
135 | 135 | if (loginStatus == true){ |
136 | | - // 存在隐藏内容,则点击回复按钮 |
| 136 | + // 存在隐藏内容,则自动回复 |
137 | 137 | var autoreply = document.querySelector('.locked a'); |
138 | 138 | if (autoreply){ |
139 | | - autoreply.click(); |
| 139 | + writeReply(); |
| 140 | + setTimeout(`window.scrollTo(0,0)`, 1000); |
140 | 141 | } |
141 | 142 | } |
142 | 143 |
|
143 | 144 | } |
144 | 145 |
|
145 | 146 |
|
146 | | - // 写入回复内容 |
| 147 | + // 写入自动回复内容 |
147 | 148 | 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(); |
174 | 155 | } |
175 | 156 | } |
176 | 157 | } |
|
0 commit comments