diff --git a/Autopage.user.js b/Autopage.user.js index be717ca..270c6bf 100644 --- a/Autopage.user.js +++ b/Autopage.user.js @@ -3,12 +3,13 @@ // @name:zh-CN 自动无缝翻页 // @name:zh-TW 自動無縫翻頁 // @name:en AutoPager -// @version 4.9.8 +// @version 4.9.9 // @author X.I.U // @description 无缝拼接下一页内容(瀑布流,追求小而美),目前支持:【所有「Discuz!、Flarum、phpBB、Xiuno、XenForo、NexusPHP」论坛】【百度、谷歌、必应、搜狗、微信、360、Yahoo、Yandex 等搜索引擎】、贴吧、豆瓣、知乎、微博、NGA、V2EX、B 站(Bilibili)、煎蛋网、糗事百科、龙的天空、起点中文、IT之家、千图网、Pixabay、Pixiv、3DM、游侠网、游民星空、NexusMods、Steam 创意工坊、CS.RIN.RU、BT之家、萌番组、动漫花园、樱花动漫、爱恋动漫、AGE 动漫、Nyaa、SrkBT、RARBG、SubHD、423Down、不死鸟、扩展迷、小众软件、【动漫狂、漫画猫、漫画屋、漫画 DB、动漫之家、拷贝漫画、包子漫画、Mangabz、Xmanhua 等漫画网站】、PubMed、Z-Library、GreasyFork、Github、StackOverflow(以上仅一小部分,更多的写不下了... // @description:zh-TW 無縫拼接下一頁內容(瀑布流,追求小而美),支持各種論壇、搜索引擎、漫畫網站~ // @description:en Seamlessly stitch next page content (waterfall)~ // @match *://*/* +// @connect userscript.xiu2.xyz // @connect www.ykmh.com // @connect www.xuexiniu.com // @connect bbs.xuexiniu.com @@ -38,6 +39,7 @@ ['menu_thread', '帖子内自动翻页 (社区类网站)', '帖子内自动翻页 (社区类网站)', true], ['menu_page_number', '显示当前页码及点击暂停翻页', '显示当前页码及点击暂停翻页', true], ['menu_pause_page', '左键双击网页空白处暂停翻页', '左键双击网页空白处暂停翻页', false], + ['menu_rules', '更新外置翻页规则', '更新外置翻页规则', {}], ['menu_customRules', '自定义翻页规则', '自定义翻页规则', {}] ], menuId = [], webType = 0, curSite = {SiteTypeID: 0}, DBSite, SiteType, pausePage = true, pageNum = {now: 1, _now: 1}, locationC = false, nowLocation = '', lp = location.pathname; window.autoPage = {src_bF: src_bF, xs_bF: xs_bF} @@ -45,8 +47,9 @@ for (let i=0;i 0 && scrollTop + clientHeight < scrollHeight) { - window.parent.scrollBy(0, delta*2); - } - }, false); - } - - // 下一页URL - curSite.pageUrl = ''; - // 自动无缝翻页 - pageLoading(); - - - // -------------------------------------------------------- - - - // [Discuz! 论坛] 判断各版块帖子列表类型 - function discuzForum(m) { - if (m == 'm') { // 手机版页面 - if (getCSS('a.loadmore')) { - curSite = DBSite.discuz_m_forum; - } else if (getCSS('.threadlist')) { - curSite = DBSite.discuz_m; curSite.pager.pageE = '.threadlist > ul > li'; - } else if (getCSS('[id^="normalthread_"]')) { - curSite = DBSite.discuz_m; curSite.pager.pageE = '[id^="normalthread_"]:not(.ZDlist)'; - } - if (curSite.SiteTypeID !== 0 && location.hostname === 'keylol.com') {curSite.history = false; locationC = true;} - } else { - if (getCSS('#autopbn')) { // 判断是否有 [下一页] 按钮 - curSite = DBSite.discuz_forum; - } else if (getCSS('#waterfall')) { // 判断是否为图片模式 - if (!getCSS('#pgbtn, .pgbtn')) { // 如果各版块帖子列表已存在这个元素,说明自带了无缝翻页 - curSite = DBSite.discuz_waterfall; waterfallStyle(); // 图片模式列表样式预处理 - } - } else { - curSite = DBSite.discuz_guide; - } - } - } - // [Discuz! 论坛] 判断手机版帖子内 - function discuzThreadM() { - if (getCSS('[id^="pid"]')) { - curSite = DBSite.discuz_m; curSite.pager.pageE = '[id^="pid"], [id^="pid"]+div:not([id="post_new"])' - } else if (getCSS('[id^="post_"]')) { - curSite = DBSite.discuz_m; curSite.pager.pageE = '[id^="post_"]'; - } - if (curSite.SiteTypeID !== 0 && location.hostname === 'keylol.com') {curSite.history = false; locationC = true;} - } - function discuz_() { - if (getCSS('body[id="nv_forum"][class^="pg_"][onkeydown*="27"]')) { - switch (getCSS('body[id="nv_forum"][class^="pg_"][onkeydown*="27"]').className) { - case 'pg_forumdisplay': // < 各版块帖子列表 > - discuzForum(); break; - case 'pg_viewthread': // < 帖子内 > - if (GM_getValue('menu_thread')) curSite = DBSite.discuz_thread; break; - case 'pg_guide': // < 导读帖子列表等 > - curSite = DBSite.discuz_guide; break; - case 'pg_collection': // < 淘贴列表 > - curSite = DBSite.discuz_collection; break; - } - } - // 如果上面没有匹配的则继续 < 搜索结果 > - if (curSite.SiteTypeID === 0) { - if (indexOF('search') || getCSS('body[id="nv_search"][onkeydown*="27"]')) { - if (indexOF('mobile=2', 's')) { // 手机版页面 - curSite = DBSite.discuz_m; curSite.pager.pageE = '.threadlist > ul > li'; locationC = true; - } else { - curSite = DBSite.discuz_search; - } - } - } - // 如果上面没有匹配的则继续 - if (curSite.SiteTypeID === 0) { - if (indexOF('.html')) { // 判断是不是静态网页(.html 结尾) - if (indexOF('/forum-')) { // < 各版块帖子列表 > - if (getXpath('//head/meta[@name="applicable-device" and @content="mobile"] | //head/title[contains(text(), "手机版")] | //head/link[contains(@href, "/mobile/")] | //head/script[contains(@src, "/mobile/")]')) { // 手机版页面 - discuzForum('m'); - } else { - discuzForum(); - } - } else if (indexOF('/thread-')) { // < 帖子内 > - if (getXpath('//head/meta[@name="applicable-device" and @content="mobile"] | //head/title[contains(text(), "手机版")] | //head/link[contains(@href, "/mobile/")] | //head/script[contains(@src, "/mobile/")]')) { // 手机版页面 - if (GM_getValue('menu_thread')) discuzThreadM(); - } else { - if (GM_getValue('menu_thread')) curSite = DBSite.discuz_thread; - } - } - } - } - // 如果上面没有匹配的则继续 - if (curSite.SiteTypeID === 0) { - if (indexOF('mod=forumdisplay', 's') || indexOF('forumdisplay.php')) { // < 各版块帖子列表 > - if (indexOF('mobile=2', 's') || indexOF('mobile=yes', 's') || getXpath('//head/meta[@name="applicable-device" and @content="mobile"] | //head/title[contains(text(), "手机版")] | //head/link[contains(@href, "/mobile/")] | //head/script[contains(@src, "/mobile/")]')) { // 手机版页面 - discuzForum('m'); - } else { - discuzForum(); - } - } else if (indexOF('mod=viewthread', 's') || indexOF('viewthread.php')) { // < 帖子内 > - if (indexOF('mobile=2', 's') || getXpath('//head/meta[@name="applicable-device" and @content="mobile"] | //head/title[contains(text(), "手机版")] | //head/link[contains(@href, "/mobile/")] | //head/script[contains(@src, "/mobile/")]')) { // 手机版页面 - if (GM_getValue('menu_thread')) discuzThreadM(); - } else { - if (GM_getValue('menu_thread')) curSite = DBSite.discuz_thread; - } - } else if (indexOF('mod=guide', 's')) { // < 导读帖子列表 > - curSite = DBSite.discuz_guide; - } else if(indexOF('mod=space', 's') && indexOF('do=thread', 's')) { // 别人的主题/回复 - curSite = DBSite.discuz_youspace; - } else if (indexOF('mod=collection', 's')) { // < 淘贴列表 > - curSite = DBSite.discuz_collection; - } else if (getCSS('#threadlist')) { // < 部分论坛的各板块 URL 是自定义的 > - discuzForum(); - } else if (getCSS('#postlist')) { // < 部分论坛的帖子内 URL 是自定义的 > - if (GM_getValue('menu_thread')) curSite = DBSite.discuz_thread; - } else { // 手机版判断 - discuzForum('m'); - if (curSite.SiteTypeID === 0) discuzThreadM(); - } - } - } - // [Discuz! 论坛] 图片模式列表样式预处理 - function waterfallStyle() { - let width = getCSS('#waterfall > li:first-child').style.width; - if (width) insStyle(`#waterfall {height: auto !important; width: 100% !important;} #waterfall > li {width: ${width} !important; float: left !important; position: inherit !important; left: auto !important; top: auto !important;}`); - } - - - // [谷歌搜索] 的插入前函数(加载视频图片) - function google_bF(pageElems) { - if (!indexOF('tbm=nws', 's')){ - pageElems.forEach(function (one) { - getAllCSS('a[aria-label][href*="https://www.youtube.com/watch?v="]').forEach(function (one1) { - let img = getCSS('img', one1) - if (img) img.src = `https://i.ytimg.com/vi/${one1.href.split('?v=')[1]}/mqdefault.jpg` - }) - }); - } - return pageElems - } - - - // [必应搜索] 的插入前函数(加载网站图标) - function bing_bF(pageElems) { - if (!getCSS('.b_title > a.sh_favicon')) { - insStyle('.b_title > a.sh_favicon {display: none !important;}'); - delete curSite.function - //console.log(curSite) - return pageElems - } - pageElems.forEach(function (one) { - getAllCSS('div.rms_iac[data-src]').forEach(function (one1) { - one1.outerHTML = `全球 Web 图标`; - }) - }); - return pageElems - } - - - // [百度贴吧](发帖按钮点击事件) - function baidu_tieba_1() { - let button = getCSS('.tbui_aside_fbar_button.tbui_fbar_post > a'); - if (button) { - button.remove(); - getCSS('li.tbui_aside_fbar_button.tbui_fbar_down').insertAdjacentHTML(getAddTo(4), '
  • ') - button = getCSS('.tbui_aside_fbar_button.tbui_fbar_post > a'); - if (button) { - button.onclick = function(){ - let button2 = getCSS('div.edui-btn.edui-btn-fullscreen.edui-btn-name-portrait'); - if (button2) {button2.click();} else {alert('提示:登录后才能发帖!');} - return false; - } - } - } - } - // [百度贴吧] 插入数据 - function baidu_tieba_insertE(pageElems, type) { - if (!pageElems) return - // 获取