Skip to content

Commit d7ccac3

Browse files
committed
优化 自动签到方式
1 parent 5d3a0cb commit d7ccac3

2 files changed

Lines changed: 55 additions & 26 deletions

File tree

52pojie-Enhanced.user.js

Lines changed: 54 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// ==UserScript==
22
// @name 吾爱破解论坛增强 - 自动签到、翻页
3-
// @version 1.2.4
3+
// @version 1.2.5
44
// @author X.I.U
5-
// @description 自动签到、自动无缝翻页(全站)、屏蔽导读悬赏贴(最新发表
5+
// @description 自动签到、自动无缝翻页、屏蔽导读悬赏贴(最新发表页
66
// @match *://www.52pojie.cn/*
77
// @icon https://www.52pojie.cn/favicon.ico
88
// @grant GM_xmlhttpRequest
@@ -19,6 +19,7 @@
1919

2020
(function() {
2121
var menu_ALL = [
22+
['menu_autoClockIn', '自动签到', '自动签到', true],
2223
['menu_thread_pageLoading', '帖子内自动翻页', '帖子内自动翻页', true],
2324
['menu_delateReward', '屏蔽导读悬赏贴(最新发表)', '屏蔽导读悬赏贴', true]
2425
], menu_ID = [];
@@ -67,17 +68,24 @@
6768
// 默认 ID 为 0
6869
var curSite = {SiteTypeID: 0};
6970

70-
// 自动翻页规则,scrollDelta 数值越大,滚动条触发点越靠上
71+
// 自动翻页规则
72+
// type:1 = 脚本实现自动无缝翻页,2 = 网站自带了自动无缝翻页功能,只需要点击下一页按钮即可,这时 nextText 为按钮文本,避免一瞬间加载太多次下一页
73+
// HT_insert:1 = 插入元素前面;2 = 插入元素中的最后一个子元素后面
74+
// scrollDelta:数值越大,滚动条触发点越靠上(越早开始翻页)
7175
let DBSite = {
7276
forum: {
7377
SiteTypeID: 1,
7478
pager: {
79+
type: 2,
80+
nextLink: '#autopbn',
81+
nextText: '下一页 »',
7582
scrollDelta: 766
7683
}
7784
},
7885
thread: {
7986
SiteTypeID: 2,
8087
pager: {
88+
type: 1,
8189
nextLink: '//div[@id="pgt"]//a[contains(text(),"下一页")][@href]',
8290
pageElement: 'css;div#postlist > div[id^="post_"]',
8391
HT_insert: ['css;div#postlist', 2],
@@ -88,6 +96,7 @@
8896
guide: {
8997
SiteTypeID: 3,
9098
pager: {
99+
type: 1,
91100
nextLink: '//div[@id="pgt"]//a[contains(text(),"下一页")][@href]',
92101
pageElement: 'css;div#threadlist div.bm_c table > tbody[id^="normalthread_"]',
93102
HT_insert: ['css;div#threadlist div.bm_c table', 2],
@@ -98,6 +107,7 @@
98107
collection: {
99108
SiteTypeID: 4,
100109
pager: {
110+
type: 1,
101111
nextLink: '//div[@class="pg"]//a[contains(text(),"下一页")][@href]',
102112
pageElement: 'css;div#ct div.bm_c table > tbody',
103113
HT_insert: ['css;div#ct div.bm_c table', 2],
@@ -108,6 +118,7 @@
108118
search: {
109119
SiteTypeID: 5,
110120
pager: {
121+
type: 1,
111122
nextLink: '//a[@class="nxt"][@href]',
112123
pageElement: 'css;div#threadlist > ul',
113124
HT_insert: ['css;div#threadlist', 2],
@@ -117,15 +128,6 @@
117128
}
118129
};
119130

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-
129131
// URL 匹配正则表达式
130132
let patt_thread = /\/thread-\d+-\d+\-\d+.html/,
131133
patt_thread_2 = /mod\=viewthread/,
@@ -150,12 +152,12 @@
150152
curSite = DBSite.collection; // 淘贴列表
151153
}else if(location.pathname === '/search.php'){
152154
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(); // 签到完成页面,关闭该标签页*/
155157
}
156158
curSite.pageUrl = ""; // 下一页URL
157159

158-
qianDao(); // 看看有没有签到
160+
qianDao(); // 自动签到
159161
pageLoading(); // 自动翻页
160162

161163

@@ -167,13 +169,13 @@
167169
let scrollTop = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
168170
let scrollDelta = curSite.pager.scrollDelta;
169171
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){ // 如果正在加载,就不再点击
173177
autopbn.click();
174178
}
175-
}else{
176-
ShowPager.loadMorePage();
177179
}
178180
}
179181
}
@@ -183,12 +185,39 @@
183185

184186

185187
// 自动签到
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+
// 自动签到(后台)
186201
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+
}
192221
}
193222
}
194223

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
| [<img src="https://www.lanzou.com/favicon.ico" height="16px" />](https://www.lanzou.com) | **蓝奏云网盘 增强 \*** | 刷新不回根目录、后退返回上一级、**右键显示菜单**、自动显示... | **[安装](https://greasyfork.org/zh-CN/scripts/419224)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Lanzou-Enhanced.user.js)** |
2828
| [<img src="https://translate.google.cn/favicon.ico" height="16px" />](https://translate.google.cn) | ~~_**Google 翻译 美化**_~~ | ~~_精简多余内容、修复翻译结果溢出屏幕问题_~~ | ~~_**[安装](https://zhuanlan.zhihu.com/p/286815739)** \| **[备用](https://zhuanlan.zhihu.com/p/286815739)**_~~ |
2929
| [<img src="https://www.52pojie.cn/favicon.ico" height="16px" />](https://www.52pojie.cn) | **吾爱破解论坛 美化** | 精简多余内容、样式优化 | **[安装](https://greasyfork.org/zh-CN/scripts/412681)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/52pojie-Beautification.user.js)** |
30-
| [<img src="https://www.52pojie.cn/favicon.ico" height="16px" />](https://www.52pojie.cn) | **吾爱破解论坛 增强** | 自动签到、**自动无缝翻页**、屏蔽导读悬赏贴(最新发表| **[安装](https://greasyfork.org/zh-CN/scripts/412680)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/52pojie-Enhanced.user.js)** |
30+
| [<img src="https://www.52pojie.cn/favicon.ico" height="16px" />](https://www.52pojie.cn) | **吾爱破解论坛 增强** | 自动签到、**自动无缝翻页**、屏蔽导读悬赏贴(最新发表页| **[安装](https://greasyfork.org/zh-CN/scripts/412680)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/52pojie-Enhanced.user.js)** |
3131
| [<img src="https://i.loli.net/2021/03/30/tvOSNCmi4rIH3Ju.png" height="16px" />](https://hostloc.com) | **全球主机交流论坛 增强 \*** | 自动无缝翻页、自动显示隐藏回复(帖子内) | **[安装](https://greasyfork.org/zh-CN/scripts/414005)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Hostloc-Enhanced.user.js)** |
3232
| [<img src="https://store.steampowered.com/favicon.ico" height="16px" />](https://store.steampowered.com) | **Steam 创意工坊大图 修复** | 修复 Steam 创意工坊预览大图无法显示的问题 | **[安装](https://greasyfork.org/zh-CN/scripts/397666)** \| **[备用](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/SteamWorkshopImageRepair.user.js)** |
3333

0 commit comments

Comments
 (0)