MCPcopy Create free account
hub / github.com/XIU2/UserScript / getNextE

Function getNextE

Autopage.user.js:2114–2132  ·  view source on GitHub ↗
(css)

Source from the content-addressed store, hash-verified

2112 }
2113 // 通用型获取下一页地址(从 元素 中获取页码)该函数用于规则中调用(fun.getNextE() 这样)
2114 function getNextE(css) {
2115 if (!css) { // 考虑到可能被非 nextL 规则内调用,所以还是需要做一个判断
2116 if (typeof curSite.pager.nextL == 'string' && curSite.pager.nextL.match(/^js;/i) === null) {css = curSite.pager.nextL;} else {return '';}
2117 }
2118 let next = getOne(css); // 获取含有下一页地址的元素
2119 if (next && next.nodeType === 1 && next.href && next.href.slice(0,4) === 'http' && next.getAttribute('href').slice(0,1) !== '#') { // 确定元素存在且 href 是正常链接
2120 if (next.href != curSite.pageUrl) { // 如果取到的下一页 URL 和上一次取到的 URL(也就是当前 URL)不一样
2121 if (curSite.pager.forceHTTPS && location.protocol === 'https:') { // 如果规则要求强制 HTTPS,且当前网页的协议也是 HTTPS,那么就需要修改 URL 为 HTTPS
2122 if (next.href.replace(/^http:/,'https:') === curSite.pageUrl) {return '';} // 如果修改为 HTTPS 后和上一次取到的 URL(也就是当前 URL)一样,就返回空
2123 return next.href.replace(/^http:/,'https:'); // 反之返回修改 HTTPS 后的 URL
2124 } else {
2125 return next.href;
2126 }
2127 } else { // 如果取到的下一页 URL 和上一次取到的 URL(也就是当前 URL)一样,那么代表没有下一页了,就返回空
2128 return '';
2129 }
2130 }
2131 return ''; // 如果元素不存在 或 href 非正常链接,就返回空
2132 }
2133 // 通用型获取下一页地址(从 元素 中获取页码,URL 替换 page= 参数)
2134 function getNextEP(css, pf, reg) {
2135 let nextNum = getOne(css), url = '';

Callers

nothing calls this directly

Calls 1

getOneFunction · 0.85

Tested by

no test coverage detected