|
48 | 48 | function menu_switch(menu_status, Name, Tips) { |
49 | 49 | if (menu_status){ |
50 | 50 | GM_setValue(`${Name}`, false); |
51 | | - GM_notification({text: `已关闭 [${Tips}] 功能\n(刷新网页后生效)`, title: '吾爱破解论坛增强', timeout: 3500}); |
| 51 | + GM_notification({text: `已关闭 [${Tips}] 功能\n(刷新网页后生效)`, title: '吾爱破解论坛增强', timeout: 3000}); |
52 | 52 | }else{ |
53 | 53 | GM_setValue(`${Name}`, true); |
54 | | - GM_notification({text: `已开启 [${Tips}] 功能\n(刷新网页后生效)`, title: '吾爱破解论坛增强', timeout: 3500}); |
| 54 | + GM_notification({text: `已开启 [${Tips}] 功能\n(刷新网页后生效)`, title: '吾爱破解论坛增强', timeout: 3000}); |
55 | 55 | } |
56 | 56 | registerMenuCommand(); // 重新注册脚本菜单 |
57 | 57 | }; |
|
61 | 61 | // 默认 ID 为 0 |
62 | 62 | var curSite = {SiteTypeID: 0}; |
63 | 63 |
|
64 | | - // 自动翻页规则,scrollDelta 数值越大,滚动条触发点越高 |
| 64 | + // 自动翻页规则,scrollDelta 数值越大,滚动条触发点越靠上 |
65 | 65 | let DBSite = { |
66 | 66 | forum: { |
67 | 67 | SiteTypeID: 1, |
|
113 | 113 |
|
114 | 114 | // 用于脚本内部判断当前 URL 类型 |
115 | 115 | let SiteType = { |
116 | | - FORUM: DBSite.forum.SiteTypeID, // 各板块帖子列表 |
117 | | - THREAD: DBSite.thread.SiteTypeID, // 帖子内 |
118 | | - GUIDE: DBSite.guide.SiteTypeID, // 导读帖子列表 |
119 | | - COLLECTION: DBSite.collection.SiteTypeID, // 淘贴列表 |
120 | | - SEARCH: DBSite.search.SiteTypeID // 搜索结果列表 |
| 116 | + FORUM: DBSite.forum.SiteTypeID, // 各板块帖子列表 |
| 117 | + THREAD: DBSite.thread.SiteTypeID, // 帖子内 |
| 118 | + GUIDE: DBSite.guide.SiteTypeID, // 导读帖子列表 |
| 119 | + COLLECTION: DBSite.collection.SiteTypeID, // 淘贴列表 |
| 120 | + SEARCH: DBSite.search.SiteTypeID // 搜索结果列表 |
121 | 121 | }; |
122 | 122 |
|
123 | 123 | // URL 匹配正则表达式 |
124 | | - var patt_thread = /\/thread-\d+-\d+\-\d+.html/, |
| 124 | + let patt_thread = /\/thread-\d+-\d+\-\d+.html/, |
125 | 125 | patt_thread_2 = /mod\=viewthread/, |
126 | 126 | patt_forum = /\/forum-\d+-\d+\.html/, |
127 | 127 | patt_forum_2 = /mod\=forumdisplay/, |
|
131 | 131 |
|
132 | 132 | // URL 判断 |
133 | 133 | if (patt_thread.test(location.pathname) || patt_thread_2.test(location.search)){ |
134 | | - // 帖子内 |
135 | 134 | if(menu_thread_pageLoading) { |
136 | | - curSite = DBSite.thread; |
137 | | - hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 |
| 135 | + curSite = DBSite.thread; // 帖子内 |
| 136 | + hidePgbtn(); // 隐藏帖子内的 [下一页] 按钮 |
138 | 137 | } |
139 | 138 | }else if (patt_forum.test(location.pathname) || patt_forum_2.test(location.search)){ |
140 | | - // 各板块帖子列表 |
141 | | - curSite = DBSite.forum; |
| 139 | + curSite = DBSite.forum; // 各板块帖子列表 |
142 | 140 | }else if (patt_guide.test(location.search)){ |
143 | | - // 导读帖子列表 |
144 | | - curSite = DBSite.guide; |
145 | | - delateReward(); // 屏蔽悬赏贴(导读-最新发表) |
| 141 | + curSite = DBSite.guide; // 导读帖子列表 |
| 142 | + delateReward(); // 屏蔽悬赏贴(导读-最新发表) |
146 | 143 | }else if (patt_collection.test(location.search)){ |
147 | | - // 淘贴列表 |
148 | | - curSite = DBSite.collection; |
| 144 | + curSite = DBSite.collection; // 淘贴列表 |
149 | 145 | }else if(location.pathname === '/search.php'){ |
150 | | - // 搜索结果列表 |
151 | | - curSite = DBSite.search; |
| 146 | + curSite = DBSite.search; // 搜索结果列表 |
152 | 147 | }else if(location.href === "https://www.52pojie.cn/home.php?mod=task&do=draw&id=2"){ |
153 | | - window.opener=null;window.open('','_self');window.close(); |
154 | | - //qianDaoBack(); // 先看看是不是签到跳转页面,如果是则返回 |
| 148 | + window.opener=null;window.open('','_self');window.close(); // 关闭当前网页标签页 |
155 | 149 | } |
156 | 150 | curSite.pageUrl = ""; // 下一页URL |
157 | 151 |
|
158 | | - qianDao(); // 看看有没有签到 |
159 | | - pageLoading(); // 自动翻页 |
| 152 | + qianDao(); // 看看有没有签到 |
| 153 | + pageLoading(); // 自动翻页 |
160 | 154 |
|
161 | 155 |
|
162 | 156 | // 自动翻页 |
163 | 157 | function pageLoading() { |
164 | 158 | if (curSite.SiteTypeID > 0){ |
165 | 159 | windowScroll(function (direction, e) { |
166 | | - //console.log('1111111') |
167 | 160 | if (direction === "down") { // 下滑才准备翻页 |
168 | | - var scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; |
| 161 | + let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; |
169 | 162 | let scrollDelta = curSite.pager.scrollDelta; |
170 | 163 | if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) { |
171 | 164 | if (curSite.SiteTypeID === SiteType.FORUM) { // 如果是原创、精品等版块则直接点下一页就行了 |
172 | | - var autopbn = document.querySelector('#autopbn'); |
173 | | - if (autopbn && autopbn.innerText == "下一页 »"){ // 如果已经在加载中了,就忽略 |
| 165 | + let autopbn = document.querySelector('#autopbn'); |
| 166 | + if (autopbn && autopbn.innerText == "下一页 »"){ // 如果没有在加载时,再去点击,免得一不注意加载几十页 |
174 | 167 | autopbn.click(); |
175 | 168 | } |
176 | 169 | }else{ |
|
185 | 178 |
|
186 | 179 | // 自动签到 |
187 | 180 | function qianDao() { |
188 | | - var qiandao = document.querySelector('#um p:last-child a:first-child'); |
| 181 | + let qiandao = document.querySelector('#um p:last-child a:first-child'); |
189 | 182 | if (qiandao){ |
190 | | - //if(qiandao.href === "https://www.52pojie.cn/home.php?mod=task&do=apply&id=2") |
191 | | - //{ |
192 | 183 | window.GM_openInTab(qiandao.href, {active: false,insert: true,setParent: true}) // 后台打开签到地址 |
193 | 184 | qiandao.querySelector('.qq_bind').setAttribute('src','https://www.52pojie.cn/static/image/common/wbs.png') // 修改 [打卡签到] 图标为 [签到完毕] |
194 | | - //qiandao.click(); |
195 | | - //} |
| 185 | + qiandao.href = "#" // 修改 URL 为 # |
196 | 186 | } |
197 | 187 | } |
198 | 188 |
|
199 | 189 |
|
200 | | - // 签到后立即返回 |
201 | | - /*function qianDaoBack() { |
202 | | - var qiandaoback = document.querySelector('#messagetext p.alert_btnleft a'); |
203 | | - if (qiandaoback){ |
204 | | - setTimeout(function(){qiandaoback.click()}, 200); |
205 | | - } |
206 | | - }*/ |
207 | | - |
208 | | - |
209 | | - // 滚动条事件 |
210 | | - function windowScroll(fn1) { |
211 | | - var beforeScrollTop = document.documentElement.scrollTop, |
212 | | - fn = fn1 || function () {}; |
213 | | - setTimeout(function () { // 延时执行,避免刚载入到页面就触发翻页事件 |
214 | | - window.addEventListener("scroll", function (e) { |
215 | | - var afterScrollTop = document.documentElement.scrollTop, |
216 | | - delta = afterScrollTop - beforeScrollTop; |
217 | | - if (delta == 0) return false; |
218 | | - fn(delta > 0 ? "down" : "up", e); |
219 | | - beforeScrollTop = afterScrollTop; |
220 | | - }, false); |
221 | | - }, 1000) |
222 | | - } |
223 | | - |
224 | | - |
225 | 190 | //屏蔽悬赏贴(导读-最新发表) |
226 | 191 | function delateReward(){ |
227 | 192 | if(patt_guide_newthread.test(location.search) && menu_delateReward){ |
228 | | - var table = document.querySelector("#threadlist > div.bm_c > table"), |
| 193 | + let table = document.querySelector("#threadlist > div.bm_c > table"), |
229 | 194 | tbodys = table.getElementsByTagName('tbody'), |
230 | 195 | arrs = []; |
231 | 196 | for (let i=0; i<tbodys.length; i++){ |
|
253 | 218 | } |
254 | 219 |
|
255 | 220 |
|
256 | | - // 监听 XMLHttpRequest 事件 |
257 | | - /*function EventXMLHttpRequest() { |
258 | | - var _send = window.XMLHttpRequest.prototype.send |
259 | | - function sendReplacement(data) { |
260 | | - if(this.onreadystatechange) { |
261 | | - this._onreadystatechange = this.onreadystatechange; |
262 | | - } |
263 | | - this.onreadystatechange = onReadyStateChangeReplacement; |
264 | | - return _send.apply(this, arguments); |
265 | | - } |
266 | | - function onReadyStateChangeReplacement() { |
267 | | - if(this._onreadystatechange) { |
268 | | - if (this.readyState==4 && this.status==200) |
269 | | - { |
270 | | - console.log('xxx') |
271 | | - } |
272 | | - } |
273 | | - return this._onreadystatechange.apply(this, arguments); |
274 | | - } |
275 | | - window.XMLHttpRequest.prototype.send = sendReplacement; |
276 | | - }*/ |
| 221 | + // 滚动条事件 |
| 222 | + function windowScroll(fn1) { |
| 223 | + var beforeScrollTop = document.documentElement.scrollTop, |
| 224 | + fn = fn1 || function () {}; |
| 225 | + setTimeout(function () { // 延时执行,避免刚载入到页面就触发翻页事件 |
| 226 | + window.addEventListener("scroll", function (e) { |
| 227 | + var afterScrollTop = document.documentElement.scrollTop, |
| 228 | + delta = afterScrollTop - beforeScrollTop; |
| 229 | + if (delta == 0) return false; |
| 230 | + fn(delta > 0 ? "down" : "up", e); |
| 231 | + beforeScrollTop = afterScrollTop; |
| 232 | + }, false); |
| 233 | + }, 1000) |
| 234 | + } |
| 235 | + |
277 | 236 |
|
278 | 237 | // 自动无缝翻页,修改自 https://greasyfork.org/scripts/14178 |
279 | 238 | function showPager() { |
|
0 commit comments