Skip to content

Commit c51b876

Browse files
committed
修复 [自动无缝翻页] 失效的规则
1 parent efea03d commit c51b876

1 file changed

Lines changed: 32 additions & 23 deletions

File tree

V2ex-Enhanced.user.js

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name V2EX 增强
3-
// @version 1.2.0
3+
// @version 1.2.1
44
// @author X.I.U
55
// @description 自动签到、链接转图片、自动无缝翻页、使用 SOV2EX 搜索、回到顶部(右键点击两侧空白处)、快速回复(左键双击两侧空白处)、新标签页打开链接、标签页伪装为 Github(摸鱼)
66
// @match *://v2ex.com/*
@@ -85,76 +85,76 @@
8585
SiteTypeID: 1,
8686
pager: {
8787
type: 1,
88-
nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
88+
nextLink: 'css;.page_current+a',
8989
pageElement: 'css;.cell.item',
90-
HT_insert: ['//div[@id="Main"]//div[@class="box"]//div[@class="cell"][last()]', 1],
91-
replaceE: 'css;#Main > .box > .cell[style]:not(.item) > table',
90+
HT_insert: ['css;.cell.ps_container:last-of-type', 1],
91+
replaceE: '//a[@class="page_current"]/../..',
9292
scrollDelta: 1500
9393
}
9494
},
9595
notifications: { // 提醒消息页
9696
SiteTypeID: 2,
9797
pager: {
9898
type: 1,
99-
nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
99+
nextLink: 'css;.page_current+a',
100100
pageElement: 'css;#notifications > div',
101101
HT_insert: ['css;#notifications', 3],
102-
replaceE: 'css;#Main > .box > .cell[style] > table',
102+
replaceE: '//a[@class="page_current"]/../..',
103103
scrollDelta: 1500
104104
}
105105
},
106106
replies: { // 用户回复页
107107
SiteTypeID: 3,
108108
pager: {
109109
type: 1,
110-
nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
111-
pageElement: '//div[@id="Main"]//div[@class="box"]//div[@class="dock_area"] | //*[@id="Main"]//div[@class="box"]//div[@class="inner"] | //*[@id="Main"]//div[@class="box"]//div[@class="dock_area"][last()]/following-sibling::div[@class="cell"][1]',
112-
HT_insert: ['//div[@id="Main"]//div[@class="box"]//div[@class="cell"][last()]', 1],
113-
replaceE: 'css;#Main > .box > .cell[style] > table',
110+
nextLink: 'css;.page_current+a',
111+
pageElement: 'css;#Main>.box>.dock_area,#Main>.box>.dock_area+.inner,#Main>.box>.dock_area+.cell:not([style])',
112+
HT_insert: ['css;.cell.ps_container:last-of-type', 1],
113+
replaceE: '//a[@class="page_current"]/../..',
114114
scrollDelta: 1500
115115
}
116116
},
117117
go: { // 分类主题页
118118
SiteTypeID: 4,
119119
pager: {
120120
type: 1,
121-
nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
121+
nextLink: 'css;.page_current+a',
122122
pageElement: 'css;#TopicsNode > div',
123123
HT_insert: ['css;#TopicsNode', 3],
124-
replaceE: 'css;#Main > .box > .cell[style] > table',
124+
replaceE: '//a[@class="page_current"]/../..',
125125
scrollDelta: 1500
126126
}
127127
},
128128
reply: { // 帖子内容页(从前往后)
129129
SiteTypeID: 5,
130130
pager: {
131131
type: 1,
132-
nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
132+
nextLink: 'css;.page_current+a',
133133
pageElement: 'css;.cell[id^="r_"]',
134-
HT_insert: ['//div[starts-with(@id, "r_")][last()]/following-sibling::div[@class="cell"][1]', 1],
135-
replaceE: 'css;#Main > .box > .cell[style] > table',
134+
HT_insert: ['css;.cell.ps_container:last-of-type', 1],
135+
replaceE: '//a[@class="page_current"]/../..',
136136
scrollDelta: 1500
137137
}
138138
},
139139
reply_positive: { // 帖子内容页(从后往前)
140140
SiteTypeID: 6,
141141
pager: {
142142
type: 1,
143-
nextLink: '//a[@class="page_current"]/preceding-sibling::a[1][@href]',
143+
nextLink: 'css;.page_current+a',
144144
pageElement: 'css;.cell[id^="r_"]',
145-
HT_insert: ['//div[starts-with(@id, "r_")][1]', 1],
146-
replaceE: 'css;#Main > .box > .cell[style] > table',
145+
HT_insert: ['css;.cell[id^="r_"]', 1],
146+
replaceE: '//a[@class="page_current"]/../..',
147147
scrollDelta: 1500
148148
}
149149
},
150150
balance: { // 账户余额页
151151
SiteTypeID: 7,
152152
pager: {
153153
type: 1,
154-
nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]',
155-
pageElement: 'css;#Main .box > div:not(.cell) > table > tbody > tr:not(:first-child)',
156-
HT_insert: ['css;#Main .box > div:not(.cell) > table > tbody', 3],
157-
replaceE: 'css;#Main > .box > .cell[style] > table',
154+
nextLink: 'css;.page_current+a',
155+
pageElement: 'css;table.data>tbody>tr:not(:first-child)',
156+
HT_insert: ['css;table.data>tbody', 3],
157+
replaceE: '//a[@class="page_current"]/../..',
158158
scrollDelta: 1000
159159
}
160160
},
@@ -470,7 +470,7 @@
470470
},
471471
loadMorePage: function () {
472472
if (curSite.pager) {
473-
let curPageEle = getElementByXpath(curSite.pager.nextLink);
473+
let curPageEle = getOneElements(curSite.pager.nextLink);
474474
var url = this.getFullHref(curPageEle);
475475
console.log(`${url} ${curPageEle} ${curSite.pageUrl}`);
476476
if(url === '') return;
@@ -576,6 +576,15 @@
576576
}
577577
return result;
578578
}
579+
function getOneElements(selector, contextNode = undefined, doc = document) {
580+
if (!selector) return;
581+
contextNode = contextNode || doc;
582+
if (selector.search(/^css;/i) === 0) {
583+
return getElementByCSS(selector.slice(4), contextNode);
584+
} else {
585+
return getElementByXpath(selector, contextNode, doc);
586+
}
587+
}
579588
function getAllElements(selector, contextNode = undefined, doc = document, win = window, _cplink = undefined) {
580589
if (!selector) return [];
581590
contextNode = contextNode || doc;

0 commit comments

Comments
 (0)