@@ -1689,35 +1689,8 @@ function: {
16891689 function getPageE ( url ) {
16901690 // Chrome 浏览器可以依靠改用原生 XMLHttpRequest 尝试解决因缺失跨域 cookie 导致的问题(比如一些使用 Cloudflare CDN 人机验证的网站,会出现脚本后台获取到人机验证页面)
16911691 // Firefox 浏览器则需要使用 GM_xmlhttpRequest 的 cookiePartition 参数来解决(该参数要 Tampermonkey v5.2 及以上才有)
1692- if ( ! curSite . gmxhr || ! navigator . userAgent . includes ( 'Firefox' ) ) {
1693- const xhr = new XMLHttpRequest ( ) ;
1694- xhr . open ( 'GET' , url , true ) ;
1695- //xhr.overrideMimeType('text/html; charset=' + (document.characterSet||document.charset||document.inputEncoding));
1696-
1697- if ( curSite . xRequestedWith === true ) { xhr . setRequestHeader ( 'x-requested-with' , 'XMLHttpRequest' ) }
1698- //(curSite.noReferer === true) ? xhr.setRequestHeader('Referer', ''):xhr.setRequestHeader('Referer', location.href)
1699- xhr . setRequestHeader ( 'Accept' , 'text/html,application/xhtml+xml,application/xml' )
1700-
1701- xhr . timeout = 5000 ;
1702- xhr . onload = function ( ) {
1703- try {
1704- //console.log('URL:' + url, '最终 URL:' + xhr.responseURL, '返回内容:' + xhr.responseText)
1705- processElems ( createDocumentByString ( xhr . responseText ) ) ;
1706- } catch ( e ) {
1707- console . error ( '[自动无缝翻页] - 处理获取到的下一页内容时出现问题,请检查!\n' , e , '\nURL:' + url , '\n最终 URL:' + xhr . responseURL , '\n返回状态:' + xhr . statusText , '\n返回内容:' + xhr . responseText ) ;
1708- }
1709- } ;
1710- xhr . onerror = function ( ) {
1711- console . log ( 'URL:' + url , xhr . statusText )
1712- GM_notification ( { text : '❌ 获取下一页失败...' , timeout : 5000 } ) ;
1713- } ;
1714- xhr . ontimeout = function ( ) {
1715- setTimeout ( function ( ) { curSite . pageUrl = '' ; } , 3000 )
1716- console . log ( 'URL:' + url , xhr . statusText )
1717- GM_notification ( { text : '❌ 获取下一页超时,可 3 秒后再次滚动网页重试(或尝试刷新网页)...' , timeout : 5000 } ) ;
1718- } ;
1719- xhr . send ( ) ;
1720- } else {
1692+ // 如果翻页规则有 curSite.gmxhr 或是 Firefox 浏览器,则依然使用 GM_xmlhttpRequest+cookiePartition,反之则使用原生 XMLHttpRequest
1693+ if ( curSite . gmxhr || navigator . userAgent . includes ( 'Firefox' ) ) {
17211694 GM_xmlhttpRequest ( {
17221695 url : url ,
17231696 method : 'GET' ,
@@ -1749,8 +1722,37 @@ function: {
17491722 GM_notification ( { text : '❌ 获取下一页超时,可 3 秒后再次滚动网页重试(或尝试刷新网页)...' , timeout : 5000 } ) ;
17501723 }
17511724 } ) ;
1725+ } else {
1726+ const xhr = new XMLHttpRequest ( ) ;
1727+ xhr . open ( 'GET' , url , true ) ;
1728+ //xhr.overrideMimeType('text/html; charset=' + (document.characterSet||document.charset||document.inputEncoding));
1729+
1730+ if ( curSite . xRequestedWith === true ) { xhr . setRequestHeader ( 'x-requested-with' , 'XMLHttpRequest' ) }
1731+ //(curSite.noReferer === true) ? xhr.setRequestHeader('Referer', ''):xhr.setRequestHeader('Referer', location.href)
1732+ xhr . setRequestHeader ( 'Accept' , 'text/html,application/xhtml+xml,application/xml' )
1733+
1734+ xhr . timeout = 5000 ;
1735+ xhr . onload = function ( ) {
1736+ try {
1737+ //console.log('URL:' + url, '最终 URL:' + xhr.responseURL, '返回内容:' + xhr.responseText)
1738+ processElems ( createDocumentByString ( xhr . responseText ) ) ;
1739+ } catch ( e ) {
1740+ console . error ( '[自动无缝翻页] - 处理获取到的下一页内容时出现问题,请检查!\n' , e , '\nURL:' + url , '\n最终 URL:' + xhr . responseURL , '\n返回状态:' + xhr . statusText , '\n返回内容:' + xhr . responseText ) ;
1741+ }
1742+ } ;
1743+ xhr . onerror = function ( ) {
1744+ console . log ( 'URL:' + url , xhr . statusText )
1745+ GM_notification ( { text : '❌ 获取下一页失败...' , timeout : 5000 } ) ;
1746+ } ;
1747+ xhr . ontimeout = function ( ) {
1748+ setTimeout ( function ( ) { curSite . pageUrl = '' ; } , 3000 )
1749+ console . log ( 'URL:' + url , xhr . statusText )
1750+ GM_notification ( { text : '❌ 获取下一页超时,可 3 秒后再次滚动网页重试(或尝试刷新网页)...' , timeout : 5000 } ) ;
1751+ } ;
1752+ xhr . send ( ) ;
17521753 }
17531754 }
1755+
17541756 // 翻页类型 4
17551757 function getPageE_ ( url , type = '' , method = 'GET' , data = '' , type2 ) {
17561758 let mimeType , accept ;
0 commit comments