Greasy Fork

Greasy Fork is available in English.

NGA Auto Pager V2

NGA自动翻页插件

当前为 2018-10-24 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        NGA Auto Pager V2
// @version     2.32
// @description NGA自动翻页插件
// @match *://bbs.nga.cn/read.php*
// @match *://bbs.nga.cn/thread.php*
// @match *://bbs.nga.cn/wow*
// @match *://bbs.nga.cn/it*
// @match *://bbs.nga.cn/auto*
// @match *://bbs.nga.cn/ink*
// @match *://bbs.nga.cn/ng2*
// @match *://bbs.nga.cn/play*
// @match *://bbs.nga.cn/tvgame*
// @match *://bbs.nga.cn/wa2*
// @match *://bbs.nga.cn/ccq*
// @match *://bbs.nga.cn/gw2*
// @match *://bbs.nga.cn/bns*
// @match *://bbs.nga.cn/heroes*
// @match *://bbs.nga.cn/lol*
// @match *://bbs.nga.cn/hs*
// @match *://bbs.nga.cn/wot*
// @match *://bbs.nga.cn/jx3*
// @match *://bbs.nga.cn/coc*
// @match *://bbs.nga.cn/pad*
// @match *://bbs.nga.cn/d3*
// @match *://bbs.nga.cn/dota*
// @match *://bbs.nga.cn/wt*
// @match *://bbs.nga.cn/ff14*
// @match *://bbs.nga.cn/poi*
// @match *://bbs.nga.cn/gta*
// @match *://bbs.nga.cn/sc*
// @match *://bbs.nga.cn/fn*
// @match *://bbs.nga.cn/ow*
// @match *://bbs.nga.cn/cr*
// @match *://bbs.nga.cn/king*
// @match *://nga.178.com/read.php*
// @match *://nga.178.com/thread.php*
// @match *://nga.178.com/wow*
// @match *://nga.178.com/it*
// @match *://nga.178.com/auto*
// @match *://nga.178.com/ink*
// @match *://nga.178.com/ng2*
// @match *://nga.178.com/play*
// @match *://nga.178.com/tvgame*
// @match *://nga.178.com/wa2*
// @match *://nga.178.com/ccq*
// @match *://nga.178.com/gw2*
// @match *://nga.178.com/bns*
// @match *://nga.178.com/heroes*
// @match *://nga.178.com/lol*
// @match *://nga.178.com/hs*
// @match *://nga.178.com/wot*
// @match *://nga.178.com/jx3*
// @match *://nga.178.com/coc*
// @match *://nga.178.com/pad*
// @match *://nga.178.com/d3*
// @match *://nga.178.com/dota*
// @match *://nga.178.com/wt*
// @match *://nga.178.com/ff14*
// @match *://nga.178.com/poi*
// @match *://nga.178.com/gta*
// @match *://nga.178.com/sc*
// @match *://nga.178.com/fn*
// @match *://nga.178.com/ow*
// @match *://nga.178.com/cr*
// @match *://nga.178.com/king*
// @author      Sunness
// @namespace http://greasyfork.icu/users/63731
// @license GPL-3.0-or-later
// ==/UserScript==

const e=document.createElement("style");e.innerHTML="#snackbar{visibility:hidden;padding:12px;right:50px;bottom:30px;background-color:#333;color:#fff;text-align:center;border-radius:6px;position:fixed}#snackbar.show{visibility:visible;-webkit-animation:fadein .5s,fadeout .5s 2.5s;animation:fadein .5s,fadeout .5s 2.5s}@-webkit-keyframes fadein{from{bottom:0;opacity:0}to{bottom:30px;opacity:1}}@keyframes fadein{from{bottom:0;opacity:0}to{bottom:30px;opacity:1}}@-webkit-keyframes fadeout{from{bottom:30px;opacity:1}to{bottom:0;opacity:0}}@keyframes fadeout{from{bottom:30px;opacity:1}to{bottom:0;opacity:0}}";const t=document.createElement("div");t.setAttribute("id","snackbar"),document.body.appendChild(e),document.body.appendChild(t);const o=document.createElement("a");o.setAttribute("id","btt"),o.setAttribute("href","#");const n=document.createElement("a");n.setAttribute("id","quick_reply"),n.setAttribute("href","#"),n.innerText="回";const i=document.createElement("a");i.setAttribute("id","next_post"),i.setAttribute("href","#");const a=document.createElement("div");a.setAttribute("id","pager_bar");const s=document.createElement("style");s.innerHTML='#pager_bar{display:flex;position:fixed;right:32px;bottom:72px;justify-content:space-evenly}#pager_bar a{margin-left:1px;visibility:hidden;background-color:#333;color:#fff;text-align:center;border-radius:6px;padding:8px;width:16px;height:16px;text-decoration:none;user-select:none}#pager_bar a:hover{color:#FFF;opacity:0.8}#pager_bar .show{visibility:visible}#btt{background:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="16px" height="16px" viewBox="0 0 16 16"><polygon fill="#FFF" points="8,2.8 16,10.7 13.6,13.1 8.1,7.6 2.5,13.2 0,10.7 "/></svg>\') center 50% no-repeat #333}#next_post{background:url(\'data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="16px" height="16px" viewBox="0 0 16 16"><polygon fill="#FFF" points="8,13.2 16,5.3 13.6,2.9 8.1,8.4 2.5,2.8 0,5.3 "/></svg>\') center 50% no-repeat #333}.fast_reply{position:fixed;left:33vw;top:25vh;background:#fff0cd;box-shadow:0 0 16px #403c33;border-radius:6px}',a.appendChild(i),a.appendChild(n),a.appendChild(o),document.body.appendChild(s),document.body.appendChild(a);const l=$("fast_post_c"),c=document.querySelector("#fast_post_c a.uitxt1"),r=document.querySelector("#fast_post_c .row1 .c2 input"),d=document.querySelector("#fast_post_c .row1 .c2 textarea");if(null!=c){const e=c.cloneNode(!0);n.addEventListener("click",t=>{t.preventDefault(),0===l.className.length?(l.className="fast_reply",c.parentNode.replaceChild(e,c)):(e.parentNode.replaceChild(c,e),l.className="")}),e.addEventListener("click",o=>{o.preventDefault(),commonui.newPost(e,postfunc.__REPLY_BLANK,window.__CURRENT_F_BIT,window.__CURRENT_FID,window.__CURRENT_TID,0,null,r.value,d.value),n.click(),t.innerHTML="正在回复",t.className="show",setTimeout(()=>{t.className=""},3e3)})}else n.setAttribute("href",document.querySelector("a.rep.uitxt1").href);const m=3e3,u=Math.round(($("topicrows")||$("m_posts")).getBoundingClientRect().top+window.scrollY);let f=!1,b=!1,_=2,w=0,g=document.querySelectorAll(".postbox"),h=1,x=!1,y=!1,v=window.pageYOffset|window.document.scrollTop;for(p of g)document.documentElement.scrollTop>p.getBoundingClientRect().top+window.scrollY&&w++;"undefined"!=typeof __PAGE&&(h=__PAGE[2],_=0===__PAGE[0].indexOf("/read")?2:1026,f=!0,2===_&&null!=n&&(y=!0,i.className="show")),o.addEventListener("click",e=>{e.preventDefault(),window.scrollTo({top:u,left:0,behavior:"smooth"}),x=!0}),i.addEventListener("click",e=>{e.preventDefault(),window.scrollTo({top:g[w].getBoundingClientRect().top+window.scrollY,left:0,behavior:"smooth"}),g.length>w+1&&w++}),window.addEventListener("scroll",async()=>{const e=window.pageYOffset||window.document.scrollTop;if(y&&(e>v?e>g[w].getBoundingClientRect().top+window.scrollY&&g.length>w+1&&w++:e<g[w-1].getBoundingClientRect().top+window.scrollY&&w>1&&w--,v=e),x&&Math.abs(e-u)<2&&(w=1,x=!1),e<1e3?(o.className="",y&&(n.className="",0!==l.className.length&&n.click())):(o.className="show",y&&(n.className="show")),f&&!b&&document.documentElement.scrollHeight-e<m){b=!0;const e=document.querySelector("a.uitxt1[title=加载下一页]");if(null!==e){t.innerHTML=`正在加载第${__PAGE[2]+1}页`,t.className="show",setTimeout(()=>{t.className=""},3e3);const e=await fetch(`${__PAGE[0]}&page=${__PAGE[2]+1}`,{credentials:"same-origin"}),o=new FileReader;o.addEventListener("loadend",()=>{const e=pr(o.result,_),t=e[1].match(/\s*<tbody/)?_$("/table"):_$("/span"),n=document.getElementsByName("pageball"),i=$("m_posts_c")||$("topicrows");eval(e[0]),t.innerHTML=e[1],t.childNodes.forEach(e=>{(1024&_&&"TBODY"==e.nodeName||"forumbox postbox"==e.className)&&i.insertBefore(e,null)}),e[2].forEach(e=>eval(e)),__PAGE[2]++,commonui.pageBtn(n[0],{0:__PAGE[0],1:__PAGE[1],2:h,3:__PAGE[3]},20),commonui.pageBtn(n[1],{0:__PAGE[0],1:__PAGE[1],2:__PAGE[2],3:__PAGE[3]},10),b=!1,g=document.querySelectorAll(".postbox")}),o.readAsText(await e.blob(),"gbk")}else f=!1}});