|
1 | 1 | // ==UserScript== |
2 | 2 | // @name 3DM论坛增强 |
3 | | -// @version 1.0.0 |
| 3 | +// @version 1.0.1 |
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 | + // 随机回复帖子的内容 |
| 16 | + var replyList = [ |
| 17 | + "感谢楼主分享!", |
| 18 | + "感谢分享,给你点赞!", |
| 19 | + "感谢分享,论坛因你更精彩!", |
| 20 | + "看看隐藏内容是什么!", |
| 21 | + "下载看看好不好用!", |
| 22 | + "好人一生平安!" |
| 23 | + ]; |
| 24 | + |
| 25 | + // 检查是否登陆 |
| 26 | + var loginStatus = false; |
| 27 | + checkLogin(); |
| 28 | + |
15 | 29 | // 默认 ID 为 0 |
16 | 30 | var curSite = {SiteTypeID: 0}; |
17 | 31 |
|
|
47 | 61 | GUIDE: DBSite.guide.SiteTypeID // 导读帖子列表 |
48 | 62 | }; |
49 | 63 |
|
| 64 | + // 下一页URL |
| 65 | + curSite.pageUrl = ""; |
| 66 | + |
50 | 67 | // URL 匹配正则表达式 |
51 | | - var patt_forum = /\/forum-\d+-\d+\.html/, |
52 | | - patt_forum_2 = /mod\=forumdisplay/, |
53 | | - patt_thread = /\/thread-\d+-\d+\-\d+.html/, |
| 68 | + var patt_thread = /\/thread-\d+-\d+\-\d+.html/, |
54 | 69 | patt_thread_2 = /mod\=viewthread/, |
55 | | - patt_guide = /mod\=guide\&view\=(hot|digest)/ |
| 70 | + patt_forum = /\/forum-\d+-\d+\.html/, |
| 71 | + patt_forum_2 = /mod\=forumdisplay/, |
| 72 | + patt_guide = /mod\=guide\&view\=(hot|digest)/, |
| 73 | + patt_reply = /mod\=post&action\=reply/ |
56 | 74 |
|
57 | 75 | // URL 判断 |
58 | 76 | if (patt_thread.test(location.pathname) || patt_thread_2.test(location.search)){ |
| 77 | + // 帖子内 |
59 | 78 | curSite = DBSite.thread; |
| 79 | + backReply(); // 先判断是否刚刚在回复帖子,如果是则返回第一页 |
| 80 | + autoReply(); // 如果有隐藏内容,则自动点击回复 |
| 81 | + pageLoading(); // 自动翻页 |
60 | 82 | }else if (patt_forum.test(location.pathname) || patt_forum_2.test(location.search)){ |
| 83 | + // 各板块帖子列表 |
61 | 84 | curSite = DBSite.forum; |
| 85 | + cleanTop(); // 清理置顶帖子 |
| 86 | + pageLoading(); // 自动翻页 |
62 | 87 | }else if (patt_guide.test(location.search)){ |
| 88 | + // 导读帖子列表 |
63 | 89 | curSite = DBSite.guide; |
| 90 | + pageLoading(); // 自动翻页 |
| 91 | + }else if (patt_reply.test(location.search)){ |
| 92 | + // 帖子回复页面 |
| 93 | + writeReply(); // 写入自动回复内容 |
64 | 94 | } |
65 | | - curSite.pageUrl = ""; // 下一页URL |
66 | 95 |
|
67 | 96 |
|
68 | | - pageLoading(); // 自动翻页 |
| 97 | + // 判断是否登陆 |
| 98 | + function checkLogin(){ |
| 99 | + var checklogin = document.querySelectorAll('.wp.h_menu p a'); |
| 100 | + if (checklogin){ |
| 101 | + for (var value of checklogin) { |
| 102 | + if (value.innerHTML == "退出"){ |
| 103 | + loginStatus = true; |
| 104 | + } |
| 105 | + } |
| 106 | + } |
| 107 | + } |
69 | 108 |
|
70 | 109 |
|
71 | 110 | // 自动翻页 |
|
91 | 130 | } |
92 | 131 |
|
93 | 132 |
|
| 133 | + // 自动点击回复 |
| 134 | + function autoReply(){ |
| 135 | + if (loginStatus == true){ |
| 136 | + // 存在隐藏内容,则点击回复按钮 |
| 137 | + var autoreply = document.querySelector('.locked a'); |
| 138 | + if (autoreply){ |
| 139 | + autoreply.click(); |
| 140 | + } |
| 141 | + } |
| 142 | + |
| 143 | + } |
| 144 | + |
| 145 | + |
| 146 | + // 写入回复内容 |
| 147 | + 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 | + } |
| 174 | + } |
| 175 | + } |
| 176 | + } |
| 177 | + |
| 178 | + |
| 179 | + // 清理置顶帖子 |
| 180 | + function cleanTop(){ |
| 181 | + var showhide = document.querySelectorAll("a.showhide.y"); |
| 182 | + if (showhide.length > 0){ |
| 183 | + showhide.forEach(el=>el.click()); |
| 184 | + } |
| 185 | + } |
| 186 | + |
| 187 | + |
94 | 188 | // 滚动条事件 |
95 | 189 | function windowScroll(fn1) { |
96 | 190 | var beforeScrollTop = document.documentElement.scrollTop, |
|
0 commit comments