Skip to content

Commit 74fc73c

Browse files
committed
优化 代码
1 parent ffba3b7 commit 74fc73c

1 file changed

Lines changed: 11 additions & 13 deletions

File tree

V2ex-Enhanced.user.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name V2ex 增强
3-
// @version 1.0.0
3+
// @version 1.0.1
44
// @author X.I.U
55
// @description 自动签到、自动无缝翻页、回到顶部(右键点击两侧空白处)
66
// @match *://v2ex.com/*
@@ -41,7 +41,7 @@
4141
menu_ALL[i][3] = GM_getValue(menu_ALL[i][0]);
4242
menu_ID[i] = GM_registerMenuCommand(`[ ${menu_ALL[i][3]?'√':'×'} ] ${menu_ALL[i][1]}`, function(){menu_switch(`${menu_ALL[i][3]}`,`${menu_ALL[i][0]}`,`${menu_ALL[i][2]}`)});
4343
}
44-
menu_ID[menu_ID.length] = GM_registerMenuCommand('反馈 & 建议', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});});
44+
menu_ID[menu_ID.length] = GM_registerMenuCommand('反馈 & 建议', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/424246/feedback', {active: true,insert: true,setParent: true});});
4545
}
4646

4747
// 菜单开关
@@ -69,7 +69,9 @@
6969
// 默认 ID 为 0
7070
var curSite = {SiteTypeID: 0};
7171

72-
// 自动翻页规则,HT_insert:1 = 插入该元素的前面;2 = 插入该元素内的最后面
72+
// 自动翻页规则
73+
// HT_insert:1 = 插入该元素的前面;2 = 插入该元素内的最后面
74+
// scrollDelta:数值越大,滚动条触发点越靠上(越早开始翻页),一般是访问网页速度越慢,该值就需要越大
7375
let DBSite = {
7476
recent: { // 最近主题页
7577
SiteTypeID: 1,
@@ -147,20 +149,19 @@
147149
case "/notifications": // 提醒消息页
148150
curSite = DBSite.notifications;
149151
break;
150-
case "/member/XIU2/replies": // 用户回复页
151-
curSite = DBSite.replies;
152-
break;
153152
default:
154153
if (location.pathname.indexOf('/go/') > -1) { // 分类主题页
155154
curSite = DBSite.go;
156155
} else if (location.pathname.indexOf('/t/') > -1) { // 帖子内容页
157-
if(menu_value('menu_pageLoading_reply'))curSite = DBSite.reply_positive;
156+
if(menu_value('menu_pageLoading_reply'))curSite = DBSite.reply_positive; // 帖子内自动无缝翻页
157+
} else if (location.pathname.indexOf('/replies') > -1) { // 用户回复页
158+
curSite = DBSite.replies;
158159
}
159160
}
160161

161162
curSite.pageUrl = ""; // 下一页URL
162163
if(menu_value('menu_autoClockIn'))setTimeout(qianDao, 1000) // 自动签到(后台),延迟 1 秒执行是为了兼容 [V2ex Plus] 扩展
163-
if(menu_value('menu_pageLoading'))pageLoading // 自动翻页(无缝)
164+
if(menu_value('menu_pageLoading'))pageLoading(); // 自动翻页(无缝)
164165
if(menu_value('menu_backToTop'))backToTop(); // 回到顶部(右键点击空白处)
165166

166167

@@ -181,7 +182,8 @@
181182
qiandao.innerText = `自动签到成功!${html}`;
182183
qiandao.href = '#';
183184
} else {
184-
GM_notification({text: '自动签到失败!请联系作者解决!', timeout: 4000});
185+
GM_notification({text: '自动签到失败!请联系作者解决!', timeout: 4000, onclick() {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});window.GM_openInTab('https://greasyfork.org/zh-CN/scripts/424246/feedback', {active: true,insert: true,setParent: true});}});
186+
qiandao.innerText = '自动签到失败!请尝试手动签到!';
185187
}
186188
}
187189
});
@@ -199,10 +201,6 @@
199201
window.scrollTo(0,0)
200202
}
201203
}
202-
/*let backToTop = `<div style="position: fixed;bottom: 0;right: 0;opacity: 0.1;"><div style="transition: height .2s ease;"><button type="button" style="display: flex;align-items: center;justify-content: center;background: #fff;border-radius: 3px;width: 200px;height: 200px;color: #8590a6;box-shadow: 0 1px 3px rgba(18,18,18,.1);border: none;cursor: pointer;outline: none;" title="回到顶部" onclick="window.scrollTo(0,0)"><svg fill="currentColor" viewBox="0 0 24 24" width="24" height="24"><path d="M16.036 19.59a1 1 0 0 1-.997.995H9.032a.996.996 0 0 1-.997-.996v-7.005H5.03c-1.1 0-1.36-.633-.578-1.416L11.33 4.29a1.003 1.003 0 0 1 1.412 0l6.878 6.88c.782.78.523 1.415-.58 1.415h-3.004v7.005z"></path></svg></button></div></div>`
203-
let backToTop_add = document.createElement('div');
204-
backToTop_add.innerHTML = `${backToTop}`;
205-
document.body.appendChild(backToTop_add);*/
206204
}
207205

208206

0 commit comments

Comments
 (0)