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

Function getNextE_

Autopage.user.js:2094–2112  ·  view source on GitHub ↗
(css)

Source from the content-addressed store, hash-verified

2092
2093 // 通用型获取下一页地址(从 元素 中获取页码)该函数仅供脚本内部调用
2094 function getNextE_(css) {
2095 if (!css) css = curSite.pager.nextL; // 如果没有指定 css 参数,那么就使用规则中的 nextL
2096 let next = getOne(css); // 获取含有下一页地址的元素
2097 if (next && next.nodeType === 1 && next.href && next.href.slice(0,4) === 'http' && next.getAttribute('href').slice(0,1) !== '#') { // 确定元素存在且 href 是正常链接
2098 if (next.href != curSite.pageUrl) { // 如果取到的下一页 URL 和上一次取到的 URL(也就是当前 URL)不一样
2099 if (curSite.pager.forceHTTPS && location.protocol === 'https:') { // 如果规则要求强制 HTTPS,且当前网页的协议也是 HTTPS,那么就需要修改 URL 为 HTTPS
2100 if (next.href.replace(/^http:/,'https:') === curSite.pageUrl) {return false;} // 如果修改为 HTTPS 后和上一次取到的 URL(也就是当前 URL)一样,就返回 false
2101 curSite.pageUrl = next.href.replace(/^http:/,'https:'); // 反之返回修改 HTTPS 后的 URL
2102 } else {
2103 curSite.pageUrl = next.href;
2104 }
2105 } else { // 如果取到的下一页 URL 和上一次取到的 URL(也就是当前 URL)一样,那么代表没有下一页了,就返回 false
2106 return false;
2107 }
2108 //console.log(curSite.pageUrl)
2109 return true;
2110 }
2111 return false; // 如果元素不存在 或 href 非正常链接,就返回false
2112 }
2113 // 通用型获取下一页地址(从 元素 中获取页码)该函数用于规则中调用(fun.getNextE() 这样)
2114 function getNextE(css) {
2115 if (!css) { // 考虑到可能被非 nextL 规则内调用,所以还是需要做一个判断

Callers 5

mangabz_nextLFunction · 0.85
dm5_nextLFunction · 0.85
xmanhua_nextLFunction · 0.85
pageLoadingFunction · 0.85
checkURLFunction · 0.85

Calls 1

getOneFunction · 0.85

Tested by

no test coverage detected