|
1 | 1 | // ==UserScript== |
2 | 2 | // @name 吾爱破解论坛增强 - 自动签到、翻页 |
3 | | -// @version 1.2.4 |
| 3 | +// @version 1.2.5 |
4 | 4 | // @author X.I.U |
5 | | -// @description 自动签到、自动无缝翻页(全站)、屏蔽导读悬赏贴(最新发表) |
| 5 | +// @description 自动签到、自动无缝翻页、屏蔽导读悬赏贴(最新发表页) |
6 | 6 | // @match *://www.52pojie.cn/* |
7 | 7 | // @icon https://www.52pojie.cn/favicon.ico |
8 | 8 | // @grant GM_xmlhttpRequest |
|
19 | 19 |
|
20 | 20 | (function() { |
21 | 21 | var menu_ALL = [ |
| 22 | + ['menu_autoClockIn', '自动签到', '自动签到', true], |
22 | 23 | ['menu_thread_pageLoading', '帖子内自动翻页', '帖子内自动翻页', true], |
23 | 24 | ['menu_delateReward', '屏蔽导读悬赏贴(最新发表)', '屏蔽导读悬赏贴', true] |
24 | 25 | ], menu_ID = []; |
|
67 | 68 | // 默认 ID 为 0 |
68 | 69 | var curSite = {SiteTypeID: 0}; |
69 | 70 |
|
70 | | - // 自动翻页规则,scrollDelta 数值越大,滚动条触发点越靠上 |
| 71 | + // 自动翻页规则 |
| 72 | + // type:1 = 脚本实现自动无缝翻页,2 = 网站自带了自动无缝翻页功能,只需要点击下一页按钮即可,这时 nextText 为按钮文本,避免一瞬间加载太多次下一页 |
| 73 | + // HT_insert:1 = 插入元素前面;2 = 插入元素中的最后一个子元素后面 |
| 74 | + // scrollDelta:数值越大,滚动条触发点越靠上(越早开始翻页) |
71 | 75 | let DBSite = { |
72 | 76 | forum: { |
73 | 77 | SiteTypeID: 1, |
74 | 78 | pager: { |
| 79 | + type: 2, |
| 80 | + nextLink: '#autopbn', |
| 81 | + nextText: '下一页 »', |
75 | 82 | scrollDelta: 766 |
76 | 83 | } |
77 | 84 | }, |
78 | 85 | thread: { |
79 | 86 | SiteTypeID: 2, |
80 | 87 | pager: { |
| 88 | + type: 1, |
81 | 89 | nextLink: '//div[@id="pgt"]//a[contains(text(),"下一页")][@href]', |
82 | 90 | pageElement: 'css;div#postlist > div[id^="post_"]', |
83 | 91 | HT_insert: ['css;div#postlist', 2], |
|
88 | 96 | guide: { |
89 | 97 | SiteTypeID: 3, |
90 | 98 | pager: { |
| 99 | + type: 1, |
91 | 100 | nextLink: '//div[@id="pgt"]//a[contains(text(),"下一页")][@href]', |
92 | 101 | pageElement: 'css;div#threadlist div.bm_c table > tbody[id^="normalthread_"]', |
93 | 102 | HT_insert: ['css;div#threadlist div.bm_c table', 2], |
|
98 | 107 | collection: { |
99 | 108 | SiteTypeID: 4, |
100 | 109 | pager: { |
| 110 | + type: 1, |
101 | 111 | nextLink: '//div[@class="pg"]//a[contains(text(),"下一页")][@href]', |
102 | 112 | pageElement: 'css;div#ct div.bm_c table > tbody', |
103 | 113 | HT_insert: ['css;div#ct div.bm_c table', 2], |
|
108 | 118 | search: { |
109 | 119 | SiteTypeID: 5, |
110 | 120 | pager: { |
| 121 | + type: 1, |
111 | 122 | nextLink: '//a[@class="nxt"][@href]', |
112 | 123 | pageElement: 'css;div#threadlist > ul', |
113 | 124 | HT_insert: ['css;div#threadlist', 2], |
|
117 | 128 | } |
118 | 129 | }; |
119 | 130 |
|
120 | | - // 用于脚本内部判断当前 URL 类型 |
121 | | - let SiteType = { |
122 | | - FORUM: DBSite.forum.SiteTypeID, // 各板块帖子列表 |
123 | | - THREAD: DBSite.thread.SiteTypeID, // 帖子内 |
124 | | - GUIDE: DBSite.guide.SiteTypeID, // 导读帖子列表 |
125 | | - COLLECTION: DBSite.collection.SiteTypeID, // 淘贴列表 |
126 | | - SEARCH: DBSite.search.SiteTypeID // 搜索结果列表 |
127 | | - }; |
128 | | - |
129 | 131 | // URL 匹配正则表达式 |
130 | 132 | let patt_thread = /\/thread-\d+-\d+\-\d+.html/, |
131 | 133 | patt_thread_2 = /mod\=viewthread/, |
|
150 | 152 | curSite = DBSite.collection; // 淘贴列表 |
151 | 153 | }else if(location.pathname === '/search.php'){ |
152 | 154 | curSite = DBSite.search; // 搜索结果列表 |
153 | | - }else if(location.href === "https://www.52pojie.cn/home.php?mod=task&do=draw&id=2"){ |
154 | | - window.opener=null;window.open('','_self');window.close(); // 关闭当前网页标签页 |
| 155 | + /*}else if(location.href === "https://www.52pojie.cn/home.php?mod=task&do=draw&id=2"){ |
| 156 | + window.opener=null;window.open('','_self');window.close(); // 签到完成页面,关闭该标签页*/ |
155 | 157 | } |
156 | 158 | curSite.pageUrl = ""; // 下一页URL |
157 | 159 |
|
158 | | - qianDao(); // 看看有没有签到 |
| 160 | + qianDao(); // 自动签到 |
159 | 161 | pageLoading(); // 自动翻页 |
160 | 162 |
|
161 | 163 |
|
|
167 | 169 | let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop; |
168 | 170 | let scrollDelta = curSite.pager.scrollDelta; |
169 | 171 | if (document.documentElement.scrollHeight <= document.documentElement.clientHeight + scrollTop + scrollDelta) { |
170 | | - if (curSite.SiteTypeID === SiteType.FORUM) { // 如果是原创、精品等版块则直接点下一页就行了 |
171 | | - let autopbn = document.querySelector('#autopbn'); |
172 | | - if (autopbn && autopbn.innerText == "下一页 »"){ // 如果没有在加载时,再去点击,免得一不注意加载几十页 |
| 172 | + if (curSite.pager.type === 1) { |
| 173 | + ShowPager.loadMorePage(); |
| 174 | + }else{ |
| 175 | + let autopbn = document.querySelector(curSite.pager.nextLink); |
| 176 | + if (autopbn && autopbn.innerText == curSite.pager.nextText){ // 如果正在加载,就不再点击 |
173 | 177 | autopbn.click(); |
174 | 178 | } |
175 | | - }else{ |
176 | | - ShowPager.loadMorePage(); |
177 | 179 | } |
178 | 180 | } |
179 | 181 | } |
|
183 | 185 |
|
184 | 186 |
|
185 | 187 | // 自动签到 |
| 188 | + /*function qianDao() { |
| 189 | + if (menu_value('menu_autoClockIn')){ |
| 190 | + let qiandao = document.querySelector('#um p:last-child a:first-child'); |
| 191 | + if (qiandao && qiandao.href === "https://www.52pojie.cn/home.php?mod=task&do=apply&id=2"){ |
| 192 | + window.GM_openInTab(qiandao.href, {active: false,insert: true,setParent: true}) // 后台打开签到地址 |
| 193 | + qiandao.querySelector('.qq_bind').setAttribute('src','https://www.52pojie.cn/static/image/common/wbs.png') // 修改 [打卡签到] 图标为 [签到完毕] |
| 194 | + qiandao.href = "#" // 修改 URL 为 # |
| 195 | + } |
| 196 | + } |
| 197 | + }*/ |
| 198 | + |
| 199 | + |
| 200 | + // 自动签到(后台) |
186 | 201 | function qianDao() { |
187 | | - let qiandao = document.querySelector('#um p:last-child a:first-child'); |
188 | | - if (qiandao && qiandao.href === "https://www.52pojie.cn/home.php?mod=task&do=apply&id=2"){ |
189 | | - window.GM_openInTab(qiandao.href, {active: false,insert: true,setParent: true}) // 后台打开签到地址 |
190 | | - qiandao.querySelector('.qq_bind').setAttribute('src','https://www.52pojie.cn/static/image/common/wbs.png') // 修改 [打卡签到] 图标为 [签到完毕] |
191 | | - qiandao.href = "#" // 修改 URL 为 # |
| 202 | + if (menu_value('menu_autoClockIn')) { |
| 203 | + let qiandao = document.querySelector('#um a[href="home.php?mod=task&do=apply&id=2"]'); |
| 204 | + if (qiandao){ |
| 205 | + GM_xmlhttpRequest({ |
| 206 | + url: qiandao.href, |
| 207 | + method: "GET", |
| 208 | + timeout: 5000, |
| 209 | + onload: function (response) { |
| 210 | + let html = ShowPager.createDocumentByString(response.responseText); |
| 211 | + html = html.querySelector('#messagetext p') |
| 212 | + if (html && html.innerText.indexOf("任务已完成") > -1) { |
| 213 | + qiandao.querySelector('.qq_bind').setAttribute('src','https://www.52pojie.cn/static/image/common/wbs.png') // 修改 [打卡签到] 图标为 [签到完毕] |
| 214 | + qiandao.href = "#" // 修改 URL 为 # |
| 215 | + }else{ |
| 216 | + GM_notification({text: '自动签到失败!请联系作者解决!', title: '吾爱破解论坛增强', timeout: 3000}); |
| 217 | + } |
| 218 | + } |
| 219 | + }); |
| 220 | + } |
192 | 221 | } |
193 | 222 | } |
194 | 223 |
|
|
0 commit comments