Skip to content

Commit 691ef41

Browse files
committed
修复 编码GBK网页乱码的问题; 优化 Firefox 浏览器下编码 GBK 网页乱码的处理方案
1 parent ddcd406 commit 691ef41

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

Autopage.user.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// @name:zh-CN 自动无缝翻页
44
// @name:zh-TW 自動無縫翻頁
55
// @name:ru Автостраничник
6-
// @version 6.6.68
6+
// @version 6.6.69
77
// @author X.I.U
88
// @description ⭐Append the next page content to the bottom seamlessly (like a waterfall, Unlimited scrolling, no need to manually click on the next page) ⭐, support various forums, social networking, games, comics, novels, academics, search engines (Google, Bing, Yahoo...) and other websites~
99
// @description:zh-CN ⭐无缝加载 下一页内容 至网页底部(类似瀑布流,无限滚动,无需手动点击下一页)⭐,目前支持:【所有「Discuz!、Flarum、phpBB、MyBB、Xiuno、XenForo、NexusPHP...」论坛】【百度、谷歌(Google)、必应(Bing)、搜狗、微信、360、Yahoo、Yandex 等搜索引擎...】、贴吧、豆瓣、知乎、NGA、V2EX、起点中文、千图网、千库网、Pixabay、Pixiv、3DM、游侠网、游民星空、NexusMods、Steam 创意工坊、CS.RIN.RU、RuTracker、BT之家、萌番组、动漫花园、樱花动漫、爱恋动漫、AGE 动漫、Nyaa、SrkBT、RARBG、SubHD、423Down、不死鸟、扩展迷、小众软件、【动漫狂、动漫屋、漫画猫、漫画屋、漫画 DB、HiComic、Mangabz、Xmanhua 等漫画网站...】、PubMed、Z-Library、GreasyFork、Github、StackOverflow(以上仅一小部分常见网站,更多的写不下了...
@@ -1695,6 +1695,7 @@ function: {
16951695
url: url,
16961696
method: 'GET',
16971697
//overrideMimeType: 'text/html; charset=' + (document.characterSet||document.charset||document.inputEncoding),
1698+
responseType: 'arraybuffer', // Firefox 浏览器下 Tampermonkey 访问 GBK 网站时会乱码,只能改为 TextDecoder 手动转换编码
16981699
headers: {
16991700
'x-requested-with': (curSite.xRequestedWith === true) ? 'XMLHttpRequest':null,
17001701
'Referer': (curSite.noReferer === true) ? null:location.href,
@@ -1706,8 +1707,9 @@ function: {
17061707
timeout: 5000,
17071708
onload: function (response) {
17081709
try {
1709-
//console.log('URL:' + url, '最终 URL:' + response.finalUrl, '返回内容:' + response.responseText)
1710-
processElems(createDocumentByString(response.responseText));
1710+
//console.log('URL:' + url, '最终 URL:' + response.finalUrl, '返回内容:' + response.responseText, response)
1711+
processElems(createDocumentByString((new TextDecoder((document.characterSet||document.charset||document.inputEncoding))).decode(response.response)));
1712+
//processElems(createDocumentByString(response.responseText));
17111713
} catch (e) {
17121714
console.error('[自动无缝翻页] - 处理获取到的下一页内容时出现问题,请检查!\n', e, '\nURL:' + url, '\n最终 URL:' + response.finalUrl, '\n返回状态:' + response.statusText, '\n返回内容:' + response.responseText);
17131715
}
@@ -1725,7 +1727,7 @@ function: {
17251727
} else {
17261728
const xhr = new XMLHttpRequest();
17271729
xhr.open('GET', url, true);
1728-
//xhr.overrideMimeType('text/html; charset=' + (document.characterSet||document.charset||document.inputEncoding));
1730+
xhr.overrideMimeType('text/html; charset=' + (document.characterSet||document.charset||document.inputEncoding));
17291731

17301732
if (curSite.xRequestedWith === true) {xhr.setRequestHeader('x-requested-with', 'XMLHttpRequest')}
17311733
//(curSite.noReferer === true) ? xhr.setRequestHeader('Referer', ''):xhr.setRequestHeader('Referer', location.href)

0 commit comments

Comments
 (0)