|
1 | 1 | // ==UserScript== |
2 | 2 | // @name V2EX 增强 |
3 | | -// @version 1.0.4 |
| 3 | +// @version 1.0.5 |
4 | 4 | // @author X.I.U |
5 | 5 | // @description 自动签到、自动无缝翻页、回到顶部(右键点击两侧空白处)、标签页伪装为 Github(摸鱼) |
6 | 6 | // @match *://v2ex.com/* |
|
71 | 71 | var curSite = {SiteTypeID: 0}; |
72 | 72 |
|
73 | 73 | // 自动翻页规则 |
74 | | - // HT_insert:1 = 插入该元素的前面;2 = 插入该元素内的最后面 |
| 74 | + // HT_insert:1 = 插入该元素本身的前面;2 = 插入该元素当中,第一个子元素前面;3 = 插入该元素当中,最后一个子元素后面;4 = 插入该元素本身的后面; |
75 | 75 | // scrollDelta:数值越大,滚动条触发点越靠上(越早开始翻页),一般是访问网页速度越慢,该值就需要越大 |
76 | 76 | let DBSite = { |
77 | 77 | recent: { // 最近主题页 |
|
91 | 91 | type: 1, |
92 | 92 | nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]', |
93 | 93 | pageElement: 'css;#notifications > div', |
94 | | - HT_insert: ['css;#notifications', 2], |
| 94 | + HT_insert: ['css;#notifications', 3], |
95 | 95 | replaceE: 'css;#Main .box > .cell:not(.item) > table', |
96 | 96 | scrollDelta: 600 |
97 | 97 | } |
|
113 | 113 | type: 1, |
114 | 114 | nextLink: '//a[@class="page_current"]/following-sibling::a[1][@href]', |
115 | 115 | pageElement: 'css;#TopicsNode > div', |
116 | | - HT_insert: ['css;#TopicsNode', 2], |
| 116 | + HT_insert: ['css;#TopicsNode', 3], |
117 | 117 | replaceE: 'css;#Main .box > .cell:not(.item) > table', |
118 | 118 | scrollDelta: 700 |
119 | 119 | } |
|
135 | 135 | type: 1, |
136 | 136 | nextLink: '//a[@class="page_current"]/preceding-sibling::a[1][@href]', |
137 | 137 | 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], |
139 | 139 | replaceE: 'css;#Main .box > .cell:not(.normalUser) > table', |
140 | 140 | scrollDelta: 700 |
141 | 141 | } |
| 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 | + } |
142 | 153 | } |
143 | 154 | }; |
144 | 155 |
|
145 | 156 |
|
146 | 157 | switch (location.pathname) { |
147 | | - case "/recent": // 最近主题页 |
| 158 | + case "/recent": // 最近主题页 |
148 | 159 | curSite = DBSite.recent; |
149 | 160 | break; |
150 | 161 | case "/notifications": // 提醒消息页 |
151 | 162 | curSite = DBSite.notifications; |
152 | 163 | break; |
| 164 | + case "/balance": // 账户余额页 |
| 165 | + curSite = DBSite.balance; |
| 166 | + break; |
153 | 167 | default: |
154 | 168 | if (location.pathname.indexOf('/go/') > -1) { // 分类主题页 |
155 | 169 | curSite = DBSite.go; |
|
161 | 175 | } |
162 | 176 |
|
163 | 177 | 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] 扩展 |
166 | 180 | if(menu_value('menu_pageLoading'))pageLoading(); // 自动翻页(无缝) |
167 | 181 | if(menu_value('menu_backToTop'))backToTop(); // 回到顶部(右键点击空白处) |
168 | 182 |
|
|
314 | 328 | let pageElems = getAllElements(curSite.pager.pageElement, newBody, newBody); |
315 | 329 | let toElement = getAllElements(curSite.pager.HT_insert[0])[0]; |
316 | 330 | 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 | + } |
319 | 347 | // 插入新页面元素 |
320 | 348 | pageElems.forEach(function (one) { |
321 | 349 | toElement.insertAdjacentElement(addTo, one); |
|
0 commit comments