Skip to content

Commit e393f0e

Browse files
committed
新增 [账户余额页] 自动无缝翻页支持
1 parent 80f79e8 commit e393f0e

1 file changed

Lines changed: 38 additions & 10 deletions

File tree

V2ex-Enhanced.user.js

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name V2EX 增强
3-
// @version 1.0.4
3+
// @version 1.0.5
44
// @author X.I.U
55
// @description 自动签到、自动无缝翻页、回到顶部(右键点击两侧空白处)、标签页伪装为 Github(摸鱼)
66
// @match *://v2ex.com/*
@@ -71,7 +71,7 @@
7171
var curSite = {SiteTypeID: 0};
7272

7373
// 自动翻页规则
74-
// HT_insert:1 = 插入该元素的前面;2 = 插入该元素内的最后面
74+
// HT_insert:1 = 插入该元素本身的前面;2 = 插入该元素当中,第一个子元素前面;3 = 插入该元素当中,最后一个子元素后面;4 = 插入该元素本身的后面;
7575
// scrollDelta:数值越大,滚动条触发点越靠上(越早开始翻页),一般是访问网页速度越慢,该值就需要越大
7676
let DBSite = {
7777
recent: { // 最近主题页
@@ -91,7 +91,7 @@
9191
type: 1,
9292
nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
9393
pageElement: 'css;#notifications > div',
94-
HT_insert: ['css;#notifications', 2],
94+
HT_insert: ['css;#notifications', 3],
9595
replaceE: 'css;#Main .box > .cell:not(.item) > table',
9696
scrollDelta: 600
9797
}
@@ -113,7 +113,7 @@
113113
type: 1,
114114
nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
115115
pageElement: 'css;#TopicsNode > div',
116-
HT_insert: ['css;#TopicsNode', 2],
116+
HT_insert: ['css;#TopicsNode', 3],
117117
replaceE: 'css;#Main .box > .cell:not(.item) > table',
118118
scrollDelta: 700
119119
}
@@ -135,21 +135,35 @@
135135
type: 1,
136136
nextLink: '//a[@class="page_current"]/preceding-sibling::a[1][@href]',
137137
pageElement: 'css;.cell[id^="r_"]',
138-
HT_insert: ['//div[starts-with(@id, "r_")][position()=1]', 1],
138+
HT_insert: ['//div[starts-with(@id, "r_")][1]', 1],
139139
replaceE: 'css;#Main .box > .cell:not(.normalUser) > table',
140140
scrollDelta: 700
141141
}
142+
},
143+
balance: { // 账户余额页
144+
SiteTypeID: 7,
145+
pager: {
146+
type: 1,
147+
nextLink: '//div[@id="Main"]//div[@class="cell"][last()]//a[@class="page_current"]/following-sibling::a[1][@href]',
148+
pageElement: '//div[@id="Main"]//div[@class="cell"][last()]/preceding-sibling::div[1]//tr[position()>1]',
149+
HT_insert: ['//div[@id="Main"]//div[@class="cell"][last()]/preceding-sibling::div[1]//tr[last()]', 4],
150+
replaceE: 'css;#Main .box .cell[style] > table',
151+
scrollDelta: 700
152+
}
142153
}
143154
};
144155

145156

146157
switch (location.pathname) {
147-
case "/recent": // 最近主题页
158+
case "/recent": // 最近主题页
148159
curSite = DBSite.recent;
149160
break;
150161
case "/notifications": // 提醒消息页
151162
curSite = DBSite.notifications;
152163
break;
164+
case "/balance": // 账户余额页
165+
curSite = DBSite.balance;
166+
break;
153167
default:
154168
if (location.pathname.indexOf('/go/') > -1) { // 分类主题页
155169
curSite = DBSite.go;
@@ -161,8 +175,8 @@
161175
}
162176

163177
curSite.pageUrl = ""; // 下一页URL
164-
if(menu_value('menu_fish'))fish() // 标签页伪装为 Github(摸鱼)
165-
if(menu_value('menu_autoClockIn'))setTimeout(qianDao, 1000) // 自动签到(后台),延迟 1 秒执行是为了兼容 [V2ex Plus] 扩展
178+
if(menu_value('menu_fish'))fish(); // 标签页伪装为 Github(摸鱼)
179+
if(menu_value('menu_autoClockIn'))setTimeout(qianDao, 1000); // 自动签到(后台),延迟 1 秒执行是为了兼容 [V2ex Plus] 扩展
166180
if(menu_value('menu_pageLoading'))pageLoading(); // 自动翻页(无缝)
167181
if(menu_value('menu_backToTop'))backToTop(); // 回到顶部(右键点击空白处)
168182

@@ -314,8 +328,22 @@
314328
let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody);
315329
let toElement = getAllElements(curSite.pager.HT_insert[0])[0];
316330
if (pageElems.length >= 0) {
317-
let addTo = "beforeend";
318-
if (curSite.pager.HT_insert[1] == 1) addTo = "beforebegin";
331+
// 插入位置
332+
let addTo;
333+
switch (curSite.pager.HT_insert[1]) {
334+
case 1:
335+
addTo = "beforebegin"
336+
break;
337+
case 2:
338+
addTo = "afterbegin"
339+
break;
340+
case 3:
341+
addTo = "beforeend"
342+
break;
343+
case 4:
344+
addTo = "afterend"
345+
break;
346+
}
319347
// 插入新页面元素
320348
pageElems.forEach(function (one) {
321349
toElement.insertAdjacentElement(addTo, one);

0 commit comments

Comments
 (0)