MCPcopy Index your code
hub / github.com/XIU2/UserScript / getNextUPN

Function getNextUPN

Autopage.user.js:2187–2212  ·  view source on GitHub ↗
(urlReg, reg, a, b = '', initP = '2', endP)

Source from the content-addressed store, hash-verified

2185 }
2186 // 通用型获取下一页地址(从 URL 中获取页码,并页码+1,URL 替换 pathname 路径,后三个参数可以省略)
2187 function getNextUPN(urlReg, reg, a, b = '', initP = '2', endP) {
2188 let nextNum = urlReg.exec(location.pathname);
2189 if (nextNum) {
2190 if (nextNum.length > 1){ // 如果正则捕获到分组(也就是正则表达式中用英文括号括起来的),那么就改为使用第一个分组(也就是正则常说的 $1)作为当前页码数字
2191 nextNum = String(parseInt(nextNum[1])+1);
2192 } else {
2193 nextNum = String(parseInt(nextNum[0])+1);
2194 }
2195 if (endP && (parseInt(nextNum) > parseInt(endP))) return ''
2196 } else {
2197 nextNum = initP;
2198 if (endP && (parseInt(nextNum) > parseInt(endP))) return ''
2199 }
2200 let url = '';
2201 if (location.pathname) {
2202 if (indexOF(reg)) {
2203 url = location.pathname.replace(reg, a + nextNum + b);
2204 } else {
2205 url = location.pathname + a + nextNum + b;
2206 }
2207 } else {
2208 url = location.pathname + a + nextNum + b;
2209 }
2210 url = location.origin + url + location.search;
2211 return url
2212 }
2213 // 通用型获取下一页地址(从 URL 中获取页码,并页码+1,URL 替换 page= 参数,后三个参数可以省略)
2214 function getNextUP(pf, reg, lp = location.pathname, initP = '2', endP) {
2215 let nextNum = getSearch(pf.replace('=','')); // 获取参数中的 page= 值

Callers

nothing calls this directly

Calls 1

indexOFFunction · 0.85

Tested by

no test coverage detected