// ==UserScript== // @name NGA Auto Pager V2 // @version 2.30 // @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 https://greasyfork.org/users/63731 // @license GPL-3.0-or-later // @downloadURL none // ==/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","#"),i.className="show";const l=document.createElement("div");l.setAttribute("id","pager_bar");const a=document.createElement("style");a.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}#pager_bar .show{visibility:visible}#btt{background:url(\'data:image/svg+xml;utf8,\') center 50% no-repeat #333}#next_post{background:url(\'data:image/svg+xml;utf8,\') center 50% no-repeat #333}.fast_reply{position:fixed;left:33vw;top:25vh;background:#fff0cd;box-shadow:0 0 16px #403c33;border-radius:6px}',l.appendChild(i),l.appendChild(n),l.appendChild(o),document.body.appendChild(a),document.body.appendChild(l);const s=$("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===s.className.length?(s.className="fast_reply",c.parentNode.replaceChild(e,c)):(e.parentNode.replaceChild(c,e),s.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=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),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(e>y?document.documentElement.scrollTop>g[w].getBoundingClientRect().top+window.scrollY&&g.length>w+1&&w++:document.documentElement.scrollTop1&&w--,y=e,x&&Math.abs(document.documentElement.scrollTop-u)<2&&(w=1,x=!1),document.documentElement.scrollTop<1e3?(o.className="",2===_&&null!=n&&(n.className="",0!==s.className.length&&n.click())):(o.className="show",2===_&&null!=n&&(n.className="show")),f&&!b&&document.documentElement.scrollHeight-document.documentElement.scrollTop{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*{(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}});