4chan/js/catalog.min.js
2025-04-17 14:46:47 -05:00

2 lines
No EOL
51 KiB
JavaScript

function checkMobileLayout(){var e,t;return window.matchMedia?window.matchMedia("(max-width: 480px)").matches&&"true"!=localStorage.getItem("4chan_never_show_mobile"):(e=$.id("boardNavMobile"),t=$.id("boardNavDesktop"),e&&t&&e.offsetWidth>0&&0===t.offsetWidth)}var $={};$.id=function(e){return document.getElementById(e)},$.cls=function(e,t){return(t||document).getElementsByClassName(e)},$.tag=function(e,t){return(t||document).getElementsByTagName(e)},$.extend=function(e,t){for(var a in t)e[a]=t[a]},$.on=function(e,t,a){e.addEventListener(t,a,!1)},$.off=function(e,t,a){e.removeEventListener(t,a,!1)},$.readCookie=function(e){var t,a,i,n;for(n=e+"=",i=document.cookie.split(";"),t=0;a=i[t];++t){for(;" "==a.charAt(0);)a=a.substring(1,a.length);if(0===a.indexOf(n))return decodeURIComponent(a.substring(n.length,a.length))}return null},document.documentElement.classList?($.hasClass=function(e,t){return e.classList.contains(t)},$.addClass=function(e,t){e.classList.add(t)},$.removeClass=function(e,t){e.classList.remove(t)}):($.hasClass=function(e,t){return-1!=(" "+e.className+" ").indexOf(" "+t+" ")},$.addClass=function(e,t){e.className=""===e.className?t:e.className+" "+t},$.removeClass=function(e,t){e.className=(" "+e.className+" ").replace(" "+t+" ","")}),$.toggleClass=function(e,t){$.hasClass(e,t)?$.removeClass(e,t):$.addClass(e,t)};var UA={};UA.init=function(){document.head=document.head||$.tag("head")[0],this.hasContextMenu="HTMLMenuItemElement"in window,this.hasWebStorage=function(){var e="catalog";try{return localStorage.setItem(e,e),localStorage.removeItem(e),!0}catch(t){return!1}}(),this.hasSessionStorage=function(){var e="catalog";try{return sessionStorage.setItem(e,e),sessionStorage.removeItem(e),!0}catch(t){return!1}}(),this.hasCORS="withCredentials"in new XMLHttpRequest,this.isMobileDevice=/Mobile|Android|Dolfin|Opera Mobi|PlayStation Vita|Nintendo DS/.test(navigator.userAgent)},UA.dispatchEvent=function(e,t){var a=document.createEvent("Event");a.initEvent(e,!1,!1),t&&(a.detail=t),document.dispatchEvent(a)};var FC=function(){function e(){var e,t,a;t=$.id("boardNavDesktop"),a=$.id("boardNavDesktopFoot"),Ke?((e=document.createElement("div")).className="pageJump",e.innerHTML='<a href="#bottom">&#9660;</a><a href="javascript:void(0);" id="settingsWindowLinkClassic">Settings</a><a href="//www.'+$L.d(Re.slug)+'" target="_top">Home</a></div>',t.appendChild(e),$.id("settingsWindowLinkClassic").addEventListener("click",Q,!1),$.addClass(t,"persistentNav")):(t.style.display="none",$.removeClass($.id("boardNavMobile"),"mobile")),Ge&&StickyNav.init(Ke),a.style.display="none",$.addClass(document.body,"hasDropDownNav")}function t(){var e,t,a;t=$.id("boardNavDesktop"),a=$.id("boardNavDesktopFoot"),Ke?((e=$.cls("pageJump",t)[0])&&($.id("settingsWindowLinkClassic").removeEventListener("click",Q,!1),t.removeChild(e)),$.removeClass(t,"persistentNav")):(t.style.display="",$.addClass($.id("boardNavMobile"),"mobile")),Ge&&StickyNav.destroy(Ke),a.style.display="",$.removeClass(document.body,"hasDropDownNav")}function a(){var e,t,a,n;UA.hasWebStorage&&!FC.hasMobileLayout&&(e=$.id("globalMessage"))&&e.textContent&&(e.nextElementSibling.style.clear="both",(t=document.createElement("span")).id="toggleMsgBtn",t.setAttribute("data-cmd","toggleMsg"),t.title="Toggle announcement",n=localStorage.getItem("4chan-global-msg"),a=e.getAttribute("data-utc"),n&&a<=n?(e.style.display="none",t.style.opacity="0.5",t.className="expandIcon"):t.className="collapseIcon",$.on(t,"click",i),e.parentNode.insertBefore(t,e))}function i(){var e,t;e=$.id("globalMessage"),t=$.id("toggleMsgBtn"),"none"==e.style.display?(e.style.display="",t.className="collapseIcon",t.style.opacity="1",localStorage.removeItem("4chan-global-msg")):(e.style.display="none",t.className="expandIcon",t.innerHTML='<span class="mobile">View Important Announcement</span>',t.style.opacity="0.5",localStorage.setItem("4chan-global-msg",e.getAttribute("data-utc")))}function n(){var e=document.getElementById("postForm");"table"==e.style.display?(e.style.display="",this.textContent="Start a New Thread"):(e.style.display="table",this.textContent="Close Post Form",window.initRecaptcha(),window.initTCaptcha())}function o(){return new RegExp("(\\"+["/",".","*","+","?","(",")","[","]","{","}","\\"].join("|\\")+")","g")}function s(e){return 1+(0|Re.threads[e].b/Re.pagesize)}function l(){var e,t,a,i;for(a=(t=$.id("styleSelector")).children,e=0;i=a[e];++e)i.value==xe&&(t.selectedIndex=e);$.on(t,"change",r)}function r(){var e;"_special"!==this.value?((e=new Date).setTime(e.getTime()+31536e6),document.cookie=Te+"="+this.value+"; expires="+e.toGMTString()+"; path=/; domain="+$L.d(Re.slug),window.css_event&&(fn=window["fc_"+window.css_event+"_cleanup"],localStorage.setItem("4chan_stop_css_event",`${window.css_event}-${window.css_event_v}`))):window.css_event&&(fn=window["fc_"+window.css_event+"_init"],localStorage.removeItem("4chan_stop_css_event")),d()}function d(e){e&&e.shiftKey||(location.href=location.href)}function c(e,t){var a;return function(){var i=arguments,n=this;clearTimeout(a),a=setTimeout(function(){t.apply(n,i)},e)}}function h(){$.hasClass(Me,"active")?m(!0):u()}function u(){var e,t=$.id("qf-cnt");$.hasClass(Me,"active")?(m(),t.style.display="none",$.removeClass(Me,"active")):(t.style.display="inline",e=$.id("qf-box"),t.hasAttribute("data-built")||(t.setAttribute("data-built","1"),$.on(e,"keyup",c(250,p)),$.on(e,"keydown",function(e){"27"==e.keyCode&&u()})),e.focus(),e.value="",$.addClass(Me,"active"))}function p(){var e,t;""!==(t=$.id("qf-box").value)?(UA.hasSessionStorage&&(sessionStorage.setItem("4chan-catalog-search",t),sessionStorage.setItem("4chan-catalog-search-board",Re.slug)),e=o(),$.id("search-term").textContent=$.id("search-term-bottom").textContent=t,$.id("search-label").style.display=$.id("search-label-bottom").style.display="inline",t=t.replace(e,"\\$1"),Ze=new RegExp(t,"i"),ye()):m()}function m(e){var t=$.id("qf-box");$.id("search-label").style.display=$.id("search-label-bottom").style.display="none",e?(t.value="",t.focus()):(UA.hasSessionStorage&&sessionStorage.removeItem("4chan-catalog-search"),Ze=!1,ye())}function f(){Ie={pin:b,hide:v,report:N},$.id("ctxmenu-main").innerHTML='<menuitem label="Unpin all threads"></menuitem>',$.id("ctxmenu-thread").innerHTML='<menuitem label="Pin/Unpin" data-cmd="pin"></menuitem><menuitem label="Hide/Unhide" data-cmd="hide"></menuitem><menuitem label="Report" data-cmd="report"></menuitem>',$.on($.id("ctxmenu-main"),"click",M),$.on($.id("ctxmenu-thread"),"click",T)}function g(){var e,t;UA.hasWebStorage&&$.on(Se,"mousedown",function(a){if(-1!=(e=a.target).className.indexOf("thumb"))if(t=e.getAttribute("data-id"),3==a.which)Se.setAttribute("contextmenu","ctxmenu-thread"),$.id("ctxmenu-thread").target=t;else{if(1==a.which&&a.altKey)return b(t),!1;if(1==a.which&&a.shiftKey)return v(t),!1}else 3==a.which&&Se.setAttribute("contextmenu","ctxmenu-main")}),_e.nobinds||$.on(document,"keyup",x)}function b(e){Ye[e]>=0?delete Ye[e]:Ye[e]=Re.threads[e].r||0,localStorage.setItem("4chan-pin-"+Re.slug,JSON.stringify(Ye)),ye()}function v(e){et?(delete qe[e],--Xe):(qe[e]=!0,++Xe),localStorage.setItem("4chan-hide-t-"+Re.slug,JSON.stringify(qe)),$.id("thread-"+e).style.display="none",C(Xe),0===Xe&&y(!1)}function y(e){et=e,$.id("filters-clear-hidden").textContent=$.id("filters-clear-hidden-bottom").textContent=e?"Back":"Show",ye()}function w(e,t){var a=e+"-label",i=e+"-count";t>0?($.id(i).textContent=$.id(i+"-bottom").textContent=t,$.id(a).style.display=$.id(a+"-bottom").style.display="inline"):$.id(a).style.display=$.id(a+"-bottom").style.display="none"}function C(e){w("hidden",e)}function k(e){w("filtered",e)}function N(e){var t,a;window.passEnabled||!window.grecaptcha?t=175:Qe?(t=320,a="&altc=1"):(t=510,a=""),window.open("https://sys."+$L.d(Re.slug)+"/"+Re.slug+"/imgboard.php?mode=report&no="+e+a,Date.now(),"toolbar=0,scrollbars=1,location=0,status=1,menubar=0,resizable=1,width=380,height="+t)}function T(e){var t=e.target.getAttribute("data-cmd");Ie[t]($.id("ctxmenu-thread").target)}function x(e){var t=e.target;"TEXTAREA"!=t.nodeName&&"INPUT"!=t.nodeName&&Oe[e.keyCode]&&Oe[e.keyCode](e)}function S(e){e.preventDefault(),Xe>0&&("Show"==$.id("filters-clear-hidden").textContent?y(!0):y(!1))}function M(){return Ye={},localStorage.removeItem("4chan-pin-"+Re.slug),ye(),!1}function L(e){var t,a=e.target;(a=e.target)!=document&&((t=a.getAttribute("data-watch"))?ThreadWatcher.toggle(t,Re.slug,Re.threads[t].sub,Re.threads[t].teaser,Re.threads[t].lr.id):(t=a.getAttribute("data-hide"))?(e.preventDefault(),v(t)):(t=a.getAttribute("data-pin"))?(e.preventDefault(),b(t)):(t=a.getAttribute("data-report"))?(e.preventDefault(),N(t)):(t=a.getAttribute("data-post-menu"))?(e.preventDefault(),PostMenu.open(a,t,ze,qe[t],Ye[t])):a.hasAttribute("data-cm-edit")?(e.preventDefault(),CustomMenu.showEditor(!0)):"backdrop"==a.id?G($.id("filters"))?G($.id("theme"))||Z():G($.id("filters-protip"))?R():I():"filter-palette"==e.target.id&&B())}function E(){var e,t,a,i,n,o,s,l,r;if(Ae=$.id("filter-palette"),a=$.id("filter-color-table"),i=$.tag("tbody",a)[0],(n=Fe.filterColors.length)>0)for(o=Fe.filterColors[0].length,e=(r=$.tag("tfoot",a)[0]).children.length-1;e>=0;e--)r.children[e].firstElementChild.setAttribute("colspan",o);for(e=0;e<n;++e){for(s=document.createElement("tr"),t=0;t<o;++t)(l=document.createElement("td")).innerHTML='<span class="button clickbox" style="background:'+Fe.filterColors[e][t]+'"></span>',$.on(l.firstElementChild,"click",Y),s.appendChild(l);i.appendChild(s)}}function W(e){var t,a=e.getBoundingClientRect();Ae||E(),$.removeClass(Ae,"hidden"),Ae.setAttribute("data-target",e.id.split("-")[2]),(t=Ae.firstElementChild).style.cssText="top:"+a.top+"px;left:"+(a.left-t.clientWidth-10)+"px;"}function A(){var e=$.id("filters-protip");e.style.top=window.pageYOffset+50+"px",$.removeClass(e,"hidden")}function I(){$.addClass($.id("filters-protip"),"hidden")}function D(e){var t=e.target;"filters-close"==t.id?R():"filters-add"==t.id?X():"filters-save"==t.id?(P(),R()):t.hasAttribute("data-active")?V(t,"active"):t.hasAttribute("data-hide")?V(t,"hide","top"):t.hasAttribute("data-top")?V(t,"top","hide"):$.hasClass(t,"filter-color")?W(t):t.hasAttribute("data-target")?z(t):t.hasAttribute("data-up")&&F(t)}function F(e){var t,a;(a=(t=e.parentNode.parentNode).previousElementSibling)&&t.parentNode.insertBefore(t,a)}function H(e){var t,a,i,n,o;for(e&&27==e.keyCode&&(this.value=""),o=this.value.toLowerCase(),i=document.getElementsByClassName("filter-pattern"),(n=document.getElementById("filter-list")).style.display="none",t=0;a=i[t];++t)-1===a.value.toLowerCase().indexOf(o)?a.parentNode.parentNode.style.display="none":a.parentNode.parentNode.style.display="";n.style.display=""}function O(){var e,t,a,i,n,o;if((t=$.id("filters"))||(t=FC.panelHTML.build("filters","panel hidden"),FC.panelHTML.build("filters-protip","panel hidden"),FC.panelHTML.build("filter-palette","hidden")),t.hasAttribute("data-built")?$.id("filters-search").value="":($.on(t,"click",D),$.on($.id("filter-palette-close"),"click",B),$.on($.id("filter-palette-clear"),"click",q),$.on($.id("filters-help-open"),"click",A),$.on($.id("filters-help-close"),"click",I),$.on($.id("filter-rgb"),"keyup",J),$.on($.id("filter-rgb-ok"),"click",Y),$.on($.id("filters-search"),"keyup",H),t.setAttribute("data-built","1")),n=0,a=localStorage.getItem("catalog-filters")){i=$.id("filter-list"),a=JSON.parse(a);for(e in a)i.appendChild(U(a[e],n)),++n;K()}t.style.top=window.pageYOffset+60+"px",$.removeClass(t,"hidden"),(o=$.cls("filter-active",t)[0])&&o.focus(),ee()}function R(){var e,t,a;for($.id("filters-msg").style.display="none",$.addClass($.id("filters"),"hidden"),t=$.id("filter-list"),e=(a=$.tag("tr",t)).length-1;e>=0;e--)t.removeChild(a[e]);B(),ee()}function B(){Ae&&!$.hasClass(Ae,"hidden")&&$.addClass(Ae,"hidden")}function _(){if(UA.hasWebStorage){Pe={};var e=localStorage.getItem("catalog-filters");if(e){e=JSON.parse(e);var t,a,i,n,s,l,r,d,c,h,u,p,m,f,g=/^\/(.*)\/(i?)$/,b=/\s*\|+\s*/g,v=/\\\*/g,y="[^\\s]*",w=o();l="(?=.*\\b",r="\\b)";try{for(a in e)if((t=e[a]).active&&""!==t.pattern){if(t.boards&&-1==t.boards.split(" ").indexOf(Re.slug))continue;if("#"==(h=t.pattern).charAt(0))f="#"==h.charAt(1)?2:1,u=new RegExp(h.slice(f).replace(w,"\\$1"));else if(f=0,d=h.match(g))u=new RegExp(d[1],d[2]);else if('"'==h.charAt(0)&&'"'==h.charAt(h.length-1))u=new RegExp(h.slice(1,-1).replace(w,"\\$1"));else{for(u="",s=(c=h.replace(b,"|").split(" ")).length,n=0;n<s;++n)if(-1!=c[n].indexOf("|")){for(m=[],i=(p=c[n].split("|")).length-1;i>=0;i--)""!==p[i]&&m.push(p[i].replace(w,"\\$1"));u+=l+"("+m.join("|").replace(v,y)+")"+r}else u+=l+c[n].replace(w,"\\$1").replace(v,y)+r;u=new RegExp("^"+u,"i")}Pe[a]={type:f,pattern:u,boards:t.boards,fid:a,hidden:t.hidden,color:t.color,top:t.top,hits:0}}}catch($){alert("There was an error processing one of the filters: "+$+" in: "+t.pattern)}}}}function P(){var e,t,a,i,n,o,s;for(i={},o=$.id("filter-list").children,e=0;t=o[e];++e)a={active:$.cls("filter-active",t)[0].checked?1:0,pattern:$.cls("filter-pattern",t)[0].value,boards:$.cls("filter-boards",t)[0].value,hidden:$.cls("filter-hide",t)[0].checked?1:0,top:$.cls("filter-top",t)[0].checked?1:0},(s=$.cls("filter-color",t)[0]).hasAttribute("data-nocolor")||(a.color=s.style.backgroundColor),i[e]=a;i[0]?localStorage.setItem("catalog-filters",JSON.stringify(i)):localStorage.removeItem("catalog-filters"),(n=$.id("filters-msg")).innerHTML="Done",n.className="msg-ok",n.style.display="inline",setTimeout(function(){n.style.display="none"},2e3),_(),ye(),K()}function J(){$.id("filter-rgb-ok").style.backgroundColor=this.value}function U(e,t){var a,i,n,o;return(i=document.createElement("tr")).id="filter-"+t,a=document.createElement("td"),(n=document.createElement("span")).setAttribute("data-up",t),n.className="pointer",n.innerHTML="&uarr;",a.appendChild(n),i.appendChild(a),a=document.createElement("td"),(o=document.createElement("input")).type="checkbox",o.checked=!!e.active,o.className="filter-active",a.appendChild(o),i.appendChild(a),a=document.createElement("td"),(o=document.createElement("input")).type="text",o.value=e.pattern,o.className="filter-pattern",a.appendChild(o),i.appendChild(a),a=document.createElement("td"),(o=document.createElement("input")).type="text",o.value=e.boards,o.className="filter-boards",a.appendChild(o),i.appendChild(a),a=document.createElement("td"),(n=document.createElement("span")).id="filter-color-"+t,n.title="Change Color",n.className="button clickbox filter-color",e.color?n.style.background=e.color:(n.setAttribute("data-nocolor","1"),n.innerHTML="&#x2215;"),a.appendChild(n),i.appendChild(a),a=document.createElement("td"),(o=document.createElement("input")).type="checkbox",o.checked=!!e.hidden,o.className="filter-hide",a.appendChild(o),i.appendChild(a),a=document.createElement("td"),(o=document.createElement("input")).type="checkbox",o.checked=!!e.top,o.className="filter-top",a.appendChild(o),i.appendChild(a),a=document.createElement("td"),(n=document.createElement("span")).setAttribute("data-target",t),n.className="pointer",n.innerHTML="&times;",a.appendChild(n),i.appendChild(a),(a=document.createElement("td")).id="fhc-"+t,a.className="filter-hits",i.appendChild(a),i}function Y(e){var t=$.id("filter-color-"+Ae.getAttribute("data-target"));!0===e?(t.setAttribute("data-nocolor","1"),t.innerHTML="&#x2215;",t.style.background=""):(t.removeAttribute("data-nocolor"),t.innerHTML="",t.style.background=this.style.backgroundColor),B()}function q(){Y(!0)}function X(){var e={active:1,pattern:"",boards:"",color:"",hidden:0,top:0,hits:0};$.id("filter-list").appendChild(U(e,j()))}function j(){var e,t,a,i=$.id("filter-list").children;if(i.length){for(a=0,e=0;t=i[e];++e)(t=+t.id.slice(7))>a&&(a=t);return a+1}return 0}function z(e){var t=$.id("filter-"+e.getAttribute("data-target"));t.parentNode.removeChild(t)}function V(e,t,a){var i,n="data-"+t;"0"==e.getAttribute(n)?(e.setAttribute(n,"1"),$.addClass(e,"active"),e.innerHTML="&#x2714;",a&&((i=$.cls("filter-"+a,e.parentNode.parentNode)[0]).setAttribute("data-"+a,"0"),$.removeClass(i,"active"),i.innerHTML="")):(e.setAttribute(n,"0"),$.removeClass(e,"active"),e.innerHTML="")}function K(){var e,t,a=$.id("filter-list").children;for(e=0;t=a[e];++e)$.id("fhc-"+t.id.slice(7)).innerHTML=Pe[e]?"x"+Pe[e].hits:""}function G(e){return e&&$.hasClass(e,"hidden")}function Q(){var e,t,a;UA.hasWebStorage?((e=$.id("theme"))||(e=FC.panelHTML.build("theme","panel hidden")),a=(a=localStorage.getItem("catalog-theme"))?JSON.parse(a):{},$.id("theme-nobinds").checked=!!a.nobinds,$.id("theme-nospoiler").checked=!!a.nospoiler,$.id("theme-newtab").checked=!!a.newtab,$.id("theme-tw").checked=ze,$.id("theme-ddn").checked=Ve,a.css&&($.id("theme-css").value=a.css),$.on($.id("theme-save"),"click",ie),$.on($.id("theme-close"),"click",Z),$.id("theme-msg").style.display="none",e.style.top=window.pageYOffset+60+"px",$.removeClass(e,"hidden"),(t=$.tag("input",e)[0])&&t.focus(),ee(),document.dispatchEvent(new CustomEvent("4chanCatalogThemeEditorReady"))):alert("Your browser doesn't support Local Storage")}function Z(){$.off($.id("theme-save"),"click",ie),$.off($.id("theme-close"),"click",Z),$.addClass($.id("theme"),"hidden"),ee()}function ee(){$.toggleClass($.id("backdrop"),"hidden")}function te(){var e;UA.hasWebStorage&&(e=localStorage.getItem("catalog-theme"))&&(_e=JSON.parse(e))}function ae(e,t){e.nobinds?_e.nobinds!=e.nobinds&&$.off(document,"keyup",x):_e.nobinds!=e.nobinds&&$.on(document,"keyup",x),e.nospoiler?$.addClass(document.body,"reveal-img-spoilers"):$.removeClass(document.body,"reveal-img-spoilers"),t||De.applyCSS(e),document.dispatchEvent(new CustomEvent("4chanCatalogThemeApplied"))}function ie(){var a,i,n,o,s,l={};$.id("theme-nobinds").checked&&(l.nobinds=!0),$.id("theme-nospoiler").checked&&(l.nospoiler=!0),$.id("theme-newtab").checked&&(l.newtab=!0),n=$.id("theme-tw").checked,o=$.id("theme-ddn").checked,s=(s=localStorage.getItem("4chan-settings"))?JSON.parse(s):{},n!=ze&&(n?(ThreadWatcher.init(),s.disableAll=!1):ThreadWatcher.unInit()),o!=Ve&&(o?(e(),s.disableAll=!1):t()),s.threadWatcher=n,s.dropDownNav=o,localStorage.setItem("4chan-settings",JSON.stringify(s)),ze=n,Ve=o,""!==(i=$.id("theme-css").value)&&(l.css=i),ae(l),localStorage.removeItem("catalog-theme");for(a in l){localStorage.setItem("catalog-theme",JSON.stringify(l));break}_e=l,ye(),Z()}function ne(e){var t,a,i=!1,n=0;if(a=localStorage.getItem(e)){n=+Object.keys(Re.threads).pop(),a=JSON.parse(a);for(t in a)!Re.threads[t]&&t<n&&(delete a[t],i=!0);for(t in a)return i&&localStorage.setItem(e,JSON.stringify(a)),a;localStorage.removeItem(e)}return{}}function oe(){UA.hasWebStorage&&(qe=ne("4chan-hide-t-"+Re.slug),Ye=ne("4chan-pin-"+Re.slug))}function se(){var e;UA.hasWebStorage&&(e=localStorage.getItem("catalog-settings"))&&$.extend(Fe,JSON.parse(e))}function le(){var e,t,a;if(UA.hasWebStorage){for(a={},e=Be.length-1;e>=0;e--)a[t=Be[e]]=Fe[t];localStorage.setItem("catalog-settings",JSON.stringify(a))}}function re(e,t){var a="";e?(Le.selectedIndex=1,a="extended-",Fe.extended=!0):(Le.selectedIndex=0,Fe.extended=!1),Fe.large?a+="large":a+="small",Se.className=a,t||le()}function de(e,t){var a=Fe.extended?"extended-":"";e?(Ee.selectedIndex=1,a+="large",Fe.large=!0):(Ee.selectedIndex=0,a+="small",Fe.large=!1),Se.className=a,t||(le(),ye())}function ce(e,t){var a={alt:0,absdate:1,date:2,r:3};a[e]!==undefined?(We.selectedIndex=a[e],Fe.orderby=e):(We.selectedIndex=0,Fe.orderby="date"),t||(le(),ye())}function he(){re("on"==Le.options[Le.selectedIndex].value)}function ue(){ce(We.options[We.selectedIndex].value)}function pe(){de("large"==Ee.options[Ee.selectedIndex].value)}function me(){"date"==Fe.orderby?ce("alt"):"alt"==Fe.orderby?ce("r"):"r"==Fe.orderby?ce("absdate"):ce("date")}function fe(e){var t=Fe.orderby;"date"==t?e.sort(function(e,t){return e.id>t.id?-1:e.id<t.id?1:0}):"absdate"!=t||Re.no_lr?"r"==t?e.sort(function(e,t){return(e=e.entry.r||0)>(t=t.entry.r||0)?-1:e<t?1:0}):e.sort(function(e,t){return e.entry.b<t.entry.b?-1:e.entry.b>t.entry.b?1:0}):e.sort(function(e,t){return(e=e.entry.lr.id)>(t=t.entry.lr.id)?-1:e<t?1:0})}function ge(){var e,t,a,i,n,o,s,l,r,d,c;c=0,r=[];e:for(e in Re.threads){if(e=+e,a=i=n=!1,(t=Re.threads[e]).sub?(o="<b>"+t.sub+"</b>",t.teaser&&(o+=": "+t.teaser)):o=t.teaser,et){if(!qe[e])continue;++Xe}else if(Ze){if(!Ze.test(o)&&!Ze.test(t.file))continue}else{if(qe[e]){++Xe;continue}if(Ye[e]>=0)n=i=!0;else{s=t.capcode?(t.trip||"")+"!#"+t.capcode:t.trip;for(d in Pe)if(0==(l=Pe[d]).type&&(l.pattern.test(o)||l.pattern.test(t.file))||1==l.type&&l.pattern.test(s)||2==l.type&&l.pattern.test(t.author)){if(l.hidden){++c,l.hits+=1;continue e}a=l,i=!!l.top,l.hits+=1;break}}}Ye[e]>=0&&(n=i=!0),r.push({id:e,entry:t,pinned:n,onTop:i,hl:a})}return je=c,r}function be(e){var t,a,i,n,o,l,r,d,c,h,u,p,m,f,g,b,v,y,w,$,C,k,N,T,x,S,M,L,E;for(m="//boards."+$L.d(Re.slug)+"/"+Re.slug+"/thread/",f="i.4cdn.org/"+Re.slug+"/",x=!Fe.large,b=_e.newtab?'target="_blank" ':"",h=Re.custom_spoiler?Fe.imgspoiler+"-"+Re.slug+Re.custom_spoiler+".png":Fe.imgspoiler+".png",p="",w="",$="",t=0;o=e[t];++t){if(i=o.id,n=o.entry,r=o.hl,d=o.onTop,c=o.pinned,n.sub?(y="<b>"+n.sub+"</b>",n.teaser&&(y+=": "+n.teaser)):y=n.teaser,l='<div id="thread-'+i+'" class="thread">',ze&&(v=i+"-"+Re.slug,l+='<span id="leaf-'+i+'" data-watch="'+i+'" '+(ThreadWatcher.watched[v]?'title="Unwatch" class="unwatchIcon"></span>':'title="Watch" class="watchIcon"></span>')),l+="<a "+b+'href="'+m+i+'"'+(n.imgspoiler?' class="imgspoiler"':"")+'><img loading="lazy" alt="" id="thumb-'+i+'" class="thumb',g=r.color?' hl" style="border-color: '+r.color:c?" pinned":"",n.imgurl?n.imgspoiler&&!_e.nospoiler?l+=g+'" src="'+h:(N=n.tn_w,T=n.tn_h,x&&(N>(k=Fe.smallsize)&&(C=k/N,N=k,T*=C),T>k&&(C=k/T,T=k,N*=C)),l+=g+'" width="'+N+'" height="'+T+'" src="//'+f+n.imgurl+"s.jpg"):n.imgdel?l+=" imgdel"+g+'" src="'+Fe.imgdel:l+=" nofile"+g+'" src="'+Fe.nofile,l+='" data-id="'+i+'" /></a>',n.sticky||n.closed||n.capcodereps){if(l+='<div class="threadIcons">',n.sticky&&(l+='<span title="Sticky" class="threadIcon stickyIcon"></span>'),n.closed&&(l+='<span title="Closed" class="threadIcon closedIcon"></span>'),n.capcodereps)for(S=n.capcodereps.split(","),a=0;M=S[a];++a)(L=He[M])&&(l+='<span title="'+L+' Replies" class="threadIcon '+M+'Icon"></span>');l+="</div>"}l+='<div title="(R)eplies / (I)mage Replies'+(d?" / (P)age":"")+'" id="meta-'+i+'" class="meta">',n.bumplimit?l+="<i>R: <b>"+n.r+"</b></i>":l+="R: <b>"+n.r+"</b>",c&&((u=n.r-Ye[i])>0?(l+=" (+"+u+")",Ye[i]=n.r):l+="(+0)"),n.i&&(n.imagelimit?l+=" / <i>I: <b>"+n.i+"</b></i>":l+=" / I: <b>"+n.i+"</b>"),d&&(E=s(i))>=0&&(l+=" / P: <b>"+E+"</b>"),l+='<a href="#" class="postMenuBtn" title="Thread Menu" data-post-menu="'+i+'">\u25b6</a>',l+="</div>",y&&(l+='<div class="teaser',r.color&&(l+=' style="color:'+r.color),l+='">'+y+"</div>"),window.partyHats?l='<div class="party-cnt">'+l+'</div><img class="party-hat" src="//s.4cdn.org/image/'+window.partyHats+'"></div>':l+="</div>",n.sticky?$+=l:d?w+=l:p+=l}return w=$+w,Ze&&""===p&&""===w?p='<div class="error">Nothing Found</div>':w?p=w+p+'<div class="clear"></div>':p+='<div class="clear"></div>',p}function ve(e){var t,a,i,n,o,s,l,r,d,c,h,u,p,m;for(h="//boards."+$L.d(Re.slug)+"/"+Re.slug+"/thread/",u=_e.newtab?'target="_blank" ':"",c="",p="",t=0;n=e[t];++t)a=n.id,i=n.entry,s=n.hl,l=n.onTop,r=n.pinned,o='<tr id="thread-'+a+'"'+(s.color?' class="hl" style="box-shadow: -3px 0 '+s.color+'"':r?' class="pinned"':"")+'><td class="txt-no">'+(m="<a "+u+'href="'+h+a+'">')+'\xbb</a></td><td class="txt-sub">'+m+i.sub+'</a></td><td class="txt-rep">',i.bumplimit?o+="<i>"+i.r+"</i>":o+=i.r,r&&((d=i.r-Ye[a])>0?(o+=" (+"+d+")",Ye[a]=i.r):o+="(+0)"),o+='</td><td class="txt-date" data-id="'+a+'">'+i.date+'</td><td class="txt-ctrl"><a href="#" class="postMenuBtn" title="Thread Menu" data-post-menu="'+a+'">\u25b6</a></td></tr>',l?p+=o:c+=o;return Ze&&""===c&&""===p?c='<div class="error">Nothing Found</div>':p?c=p+c+'<div class="clear"></div>':c+='<div class="clear"></div>',c='<table><thead><tr><th class="txt-no"></th><th class="txt-sub">Subject</th><th class="txt-rep">Replies</th><th class="txt-date">Date</th><th class="txt-ctrl"></th></tr></thead><tbody>'+c+"</tbody></table>"}function ye(){var e,t,a,i;if(0!==Re.count){Se.hasChildNodes()&&((t=document.getElementById("th-tip"))&&document.body.removeChild(t),Se.textContent=""),Xe=0,je=0;for(a in Pe)Pe[a].hits=0;fe(i=ge()),window.text_only?Se.innerHTML=ve(i):Se.innerHTML=be(i);for(e in Ye){localStorage.setItem("4chan-pin-"+Re.slug,JSON.stringify(Ye));break}k(je),C(Xe)}}function we(e){var t=e.target;($.hasClass(t,"thumb")||window.text_only&&$.hasClass(t,"txt-date"))&&(clearTimeout(Ue),Je&&ke(),Ue=setTimeout(Ce,Fe.tipdelay,t))}function $e(){clearTimeout(Ue),Je&&ke()}function Ce(e){var t,a,i,n,o,l,r,d,c,h,u,p,m;t=Date.now()/1e3,n=e.getBoundingClientRect(),o=document.documentElement.offsetWidth,(d=e.getAttribute("data-id"))&&(c=Re.threads[d],r=(r=s(d))?'<span class="post-page">Page '+r+"</span>":"",a=c.sub&&!window.text_only?'<span class="post-subject">'+c.sub+"</span>":"Posted",a+=' by <span class="'+(c.capcode?c.capcode+"-capcode ":"")+'post-author">'+(c.author||Re.anon),c.trip&&(a+=' <span class="post-tripcode">'+c.trip+"</span>"),c.capcode&&(a+=" ## "+He[c.capcode]),a+="</span> ",Re.flags&&c.country&&(a+='<div class="flag flag-'+c.country.toLowerCase()+'"></div> '),a+='<span class="post-ago">'+Ne(t-c.date)+" ago</span>"+r,(!Fe.extended&&c.teaser||window.text_only)&&(a+='<p class="post-teaser">'+c.teaser+"</p>"),c.lr.date&&(a+='<div class="post-last">Last reply by <span class="'+(c.lr.capcode?c.lr.capcode+"-capcode ":"")+'post-author">'+c.lr.author,c.lr.trip&&(a+=' <span class="post-tripcode">'+c.lr.trip+"</span>"),c.lr.capcode&&(a+=" ## "+c.lr.capcode.charAt(0).toUpperCase()+c.lr.capcode.slice(1)),c.lr.date?a+='</span> <span class="post-ago">'+Ne(t-c.lr.date)+" ago</span>":a+="</span>"),(i=document.createElement("div")).id="post-preview",i.innerHTML=a,document.body.appendChild(i),m=o-n.right<(0|.3*o)?n.left-i.offsetWidth-5:n.left+n.width+5,p=document.documentElement.clientHeight,(h=(u=n.top+i.offsetHeight)>p?n.top-(u-p)-20:n.top)<0&&(h=3),(l=i.style).left=m+window.pageXOffset+"px",l.top=h+window.pageYOffset+"px",Je=!0)}function ke(){document.body.removeChild($.id("post-preview")),Je=!1}function Ne(e,t){var a,i,n;return e<2?"less than a second":t&&e<300?(0|e)+" seconds":e<60?(0|e)+" seconds":e<3600?(a=0|e/60)>1?a+" minutes":"one minute":e<86400?(i=(a=0|e/3600)>1?a+" hours":"one hour",(n=0|e/60-60*a)>1&&(i+=" and "+n+" minutes"),i):(i=(a=0|e/86400)>1?a+" days":"one day",(n=0|e/3600-24*a)>1&&(i+=" and "+n+" hours"),i)}var Te,xe,Se,Me,Le,Ee,We,Ae,Ie,De=this,Fe={orderby:"alt",large:!1,extended:!0,imgdel:"//s.4cdn.org/image/filedeleted-res.gif",imgspoiler:"//s.4cdn.org/image/spoiler",nofile:"//s.4cdn.org/image/nofile.png",smallsize:150,tipdelay:250,filterColors:[["#E0B0FF","#F2F3F4","#7DF9FF","#FFFF00"],["#FBCEB1","#FFBF00","#ADFF2F","#0047AB"],["#00A550","#007FFF","#AF0A0F","#B5BD68"]]},He={admin:"Administrator",mod:"Moderator",developer:"Developer",manager:"Manager",founder:"Founder",verified:"Verified"},Oe={83:h,82:d,88:me},Re={},Be=["orderby","large","extended"],_e={},Pe={},Je=!1,Ue=null,Ye={},qe={},Xe=0,je=0,ze=!1,Ve=!1,Ke=!1,Ge=!1,Qe=!1,Ze=!1,et=!1;window.devicePixelRatio>=2&&(Fe.imgdel.replace(".","@2x."),Fe.nofile.replace(".","@2x.")),UA.init(),te(),De.init=function(){var t,i,o,s;FC.hasMobileLayout=checkMobileLayout(),ae(_e,!0),Se=$.id("threads"),Me=$.id("qf-ctrl"),Le=$.id("teaser-ctrl"),Ee=$.id("size-ctrl"),We=$.id("order-ctrl"),$.on(Me,"click",u),$.on($.id("filters-clear-hidden"),"click",S),$.on($.id("filters-clear-hidden-bottom"),"click",S),$.on($.id("qf-clear"),"click",u),$.on($.id("settingsWindowLink"),"click",Q),$.on($.id("settingsWindowLinkBot"),"click",Q),$.on($.id("settingsWindowLinkMobile"),"click",Q),$.on($.id("filters-ctrl"),"click",O),$.on(Le,"change",he),$.on(Ee,"change",pe),$.on(We,"change",ue),$.on(Se,"mouseover",we),$.on(Se,"mouseout",$e),$.on($.id("togglePostFormLinkMobile"),"click",n),$.on(document,"click",L),se(),g(),a(),UA.hasContextMenu&&f(),window.Config={},UA.hasWebStorage&&((t=localStorage.getItem("4chan-settings"))?(t=JSON.parse(t),window.Config=t,t.disableAll||(CustomMenu.initCtrl(t.dropDownNav,t.classicNav),t.filter&&(ThreadWatcher.hasFilters=!0),t.threadWatcher&&(ze=!0,ThreadWatcher.init()),t.customMenu&&CustomMenu.apply(t.customMenuList),!1===t.dropDownNav||FC.hasMobileLayout||(Ve=!0,Ke=t.classicNav,Ge=t.autoHideNav,e()),Qe=t.altCaptcha)):UA.isMobileDevice&&!FC.hasMobileLayout?(Ve=!0,e()):CustomMenu.initCtrl(!1,!1),window.css_event&&"_special"===xe&&(s=window["fc_"+window.css_event+"_init"])&&s()),(i=document.forms.post.flag)&&(o=$.readCookie("4chan_flag"))&&(i=i.querySelector('option[value="'+o+'"]'))&&i.setAttribute("selected","selected"),ce(Fe.orderby,!0),de(Fe.large,!0),re(Fe.extended,!0),UA.dispatchEvent("4chanMainInit")},De.loadCatalog=function(e){var t;Re=e,$.addClass(document.body,xe.toLowerCase().replace(/ /g,"_")),l(),_(),oe(),UA.hasSessionStorage&&!location.hash&&(t=sessionStorage.getItem("4chan-catalog-search"))?Re.slug!=sessionStorage.getItem("4chan-catalog-search-board")&&(sessionStorage.removeItem("4chan-catalog-search"),sessionStorage.removeItem("4chan-catalog-search-board"),t=null):location.hash&&(t=location.hash.match(/#s=(.+)/))&&(t=decodeURIComponent(t[1].replace(/\+/g," "))),t?(u(),$.id("qf-box").value=t,p()):ye()},De.applyCSS=function(e,t,a){var i,n;e||(e=_e),t!==undefined&&((n=$.readCookie(t))||(n="nws_style"==t?"Yotsuba New":"Yotsuba B New"),Te=t,window.css_event&&localStorage.getItem("4chan_stop_css_event")!==`${window.css_event}-${window.css_event_v}`?(xe="_special",n=window.css_event):xe=n,(i=document.createElement("link")).type="text/css",i.id="base-css",i.rel="stylesheet",i.setAttribute("href","//s.4cdn.org/css/catalog_"+n.toLowerCase().replace(/ /g,"_")+"."+a+".css"),document.head.insertBefore(i,$.id("mobile-css"))),(i=$.id("custom-css"))&&document.head.removeChild(i),e.css&&((i=document.createElement("style")).type="text/css",i.id="custom-css",i.styleSheet?i.styleSheet.cssText=e.css:i.innerHTML=e.css,document.head.appendChild(i))}},Filter={};Filter.init=function(){this.entities=document.createElement("div"),Filter.load()},Filter.match=function(e,t){var a,i,n,o,s;for(s=!1,o=Filter.activeFilters,a=0;n=o[a];++a)if(n.boards[t])if(0==n.type){if(n.pattern===e.trip){s=!0;break}}else if(1==n.type){if(n.pattern===e.name){s=!0;break}}else if(2==n.type&&e.com){if(i===undefined&&(this.entities.innerHTML=e.com.replace(/<br>/g,"\n").replace(/[<[^>]+>/g,""),i=this.entities.textContent),n.pattern.test(i)){s=!0;break}}else if(4==n.type){if(n.pattern===e.id){s=!0;break}}else if(5==n.type){if(n.pattern.test(e.sub)){s=!0;break}}else if(6==n.type&&n.pattern.test(e.filename)){s=!0;break}return s},FC.getDocTopOffset=function(){return window.Config.dropDownNav&&!window.Config.autoHideNav?$.id(window.Config.classicNav?"boardNavDesktop":"boardNavMobile").offsetHeight:0},Filter.load=function(){var e,t,a,i,n,o,s,l,r,d,c,h,u,p,m,f,g;if(this.activeFilters=[],i=localStorage.getItem("4chan-filters")){i=JSON.parse(i),s=new RegExp("(\\"+["/",".","*","+","?","(",")","[","]","{","}","\\","^","$"].join("|\\")+")","g"),l=/^\/(.*)\/(i?)$/,r="(?=.*\\b",d="\\b)",h=/\\\*/g,u="[^\\s]*";try{for(o=0;a=i[o];++o)if(a.active&&""!==a.pattern){if(a.boards)for(g=a.boards.split(/[^a-z0-9]+/i),p={},e=0;t=g[e];++e)p[t]=!0;else p=!1;if(n=a.pattern,a.type&&1!=a.type&&4!=a.type)if(f=n.match(l))m=new RegExp(f[1],f[2]);else if('"'==n[0]&&'"'==n[n.length-1])m=new RegExp(n.slice(1,-1).replace(s,"\\$1"));else{for(m="",e=0,t=(c=n.split(" ")).length;e<t;++e)m+=r+c[e].replace(s,"\\$1").replace(h,u)+d;m=new RegExp("^"+m,"im")}else m=n;this.activeFilters.push({type:a.type,pattern:m,boards:p,color:a.color,hide:a.hide,auto:a.auto})}}catch(b){alert("There was an error processing one of the filters: "+b+" in: "+n)}}};var ThreadWatcher={hasFilters:!1};ThreadWatcher.init=function(){var e,t;this.hasFilters&&Filter.init(),this.listNode=null,this.charLimit=45,this.watched={},this.blacklisted={},this.isRefreshing=!1,FC.hasMobileLayout&&((t=document.createElement("a")).href="#",t.textContent="TW",t.addEventListener("click",ThreadWatcher.toggleList,!1),(e=$.id("settingsWindowLinkMobile")).parentNode.insertBefore(t,e),e.parentNode.insertBefore(document.createTextNode(" "),e)),(e=document.createElement("div")).id="threadWatcher",e.setAttribute("data-trackpos","TW-position"),FC.hasMobileLayout?e.style.display="none":window.Config["TW-position"]?e.style.cssText=window.Config["TW-position"]:(e.style.left="10px",
e.style.top="75px"),e.innerHTML='<div class="drag" id="twHeader">'+(FC.hasMobileLayout?'<div id="twClose" class="icon closeIcon"></div>':"")+"Thread Watcher"+(UA.hasCORS?'<div id="twPrune" class="icon refreshIcon" title="Refresh"></div></div>':"</div>"),this.listNode=document.createElement("ul"),this.listNode.id="watchList",this.load(),this.build(),e.appendChild(this.listNode),document.body.appendChild(e),e.addEventListener("mouseup",this.onClick,!1),Draggable.set($.id("twHeader")),window.addEventListener("storage",this.syncStorage,!1),!FC.hasMobileLayout&&this.canAutoRefresh()&&this.refresh()},ThreadWatcher.unInit=function(){var e;(e=$.id("threadWatcher"))&&(e.removeEventListener("mouseup",this.onClick,!1),Draggable.unset($.id("twHeader")),window.removeEventListener("storage",this.syncStorage,!1),document.body.removeChild(e))},ThreadWatcher.toggleList=function(e){var t=$.id("threadWatcher");e&&e.preventDefault(),ThreadWatcher.canAutoRefresh()&&ThreadWatcher.refresh(),"none"==t.style.display?(t.style.top=window.pageYOffset+30+"px",t.style.display=""):t.style.display="none"},ThreadWatcher.syncStorage=function(e){var t;e.key&&"4chan"==(t=e.key.split("-"))[0]&&"watch"==t[1]&&e.newValue!=e.oldValue&&(ThreadWatcher.load(),ThreadWatcher.build())},ThreadWatcher.load=function(){var e;(e=localStorage.getItem("4chan-watch"))&&(this.watched=JSON.parse(e)),(e=localStorage.getItem("4chan-watch-bl"))&&(this.blacklisted=JSON.parse(e))},ThreadWatcher.build=function(){var e,t,a,i;e="";for(a in this.watched)e+='<li id="watch-'+a+'"><span class="pointer" data-cmd="unwatch" data-id="'+(t=a.split("-"))[0]+'" data-board="'+t[1]+'">&times;</span> <a href="'+this.linkToThread(t[0],t[1],this.watched[a][1])+'"',-1==this.watched[a][1]?e+=' class="deadlink">':(i=[],this.watched[a][3]&&i.push("archivelink"),this.watched[a][4]&&(i.push("hasYouReplies"),e+=' title="This thread has replies to your posts"'),this.watched[a][2]?e+=' class="'+(i[0]?i.join(" ")+" ":"")+'hasNewReplies">('+this.watched[a][2]+") ":e+=(i[0]?'class="'+i.join(" ")+'"':"")+">"),e+="/"+t[1]+"/ - "+this.watched[a][0]+"</a></li>";ThreadWatcher.listNode.innerHTML=e},ThreadWatcher.onClick=function(e){var t=e.target;t.hasAttribute("data-id")?ThreadWatcher.toggle(t.getAttribute("data-id"),t.getAttribute("data-board")):"twPrune"!=t.id||ThreadWatcher.isRefreshing?"twClose"==t.id&&ThreadWatcher.toggleList():ThreadWatcher.refreshWithAutoWatch()},ThreadWatcher.generateLabel=function(e,t,a){var i;return i=(i=e)?i.slice(0,this.charLimit):(i=t)?i.replace(/(?:<br>)+/g," ").replace(/<[^>]*?>/g,"").slice(0,this.charLimit):"No."+a},ThreadWatcher.toggle=function(e,t,a,i,n){var o,s,l,r;o=e+"-"+t,r=$.id("leaf-"+e),this.watched[o]?(delete this.watched[o],r&&(r.className="watchIcon",r.title="Watch")):(s=ThreadWatcher.generateLabel(a,i,e),l=n||e,this.watched[o]=[s,l,0],r.className="unwatchIcon",r.title="Unwatch"),this.save(),this.load(),this.build()},ThreadWatcher.addRaw=function(e,t){var a,i;a=e.no+"-"+t,this.watched[a]||(i=ThreadWatcher.generateLabel(e.sub,e.com,e.no),this.watched[a]=[i,0,0])},ThreadWatcher.save=function(){var e;ThreadWatcher.sortByBoard(),localStorage.setItem("4chan-watch",JSON.stringify(ThreadWatcher.watched));for(e in ThreadWatcher.blacklisted){localStorage.setItem("4chan-watch-bl",JSON.stringify(ThreadWatcher.blacklisted));break}},ThreadWatcher.sortByBoard=function(){var e,t,a,i,n;t=ThreadWatcher,i={},n=[];for(a in t.watched)n.push(a);for(n.sort(function(e,t){return(e=e.split("-")[1])<(t=t.split("-")[1])?-1:e>t?1:0}),e=0;a=n[e];++e)i[a]=t.watched[a];t.watched=i},ThreadWatcher.canAutoRefresh=function(){var e;return!!(e=localStorage.getItem("4chan-tw-timestamp"))&&Date.now()-+e>=6e4},ThreadWatcher.setRefreshTimestamp=function(){localStorage.setItem("4chan-tw-timestamp",Date.now())},ThreadWatcher.refreshWithAutoWatch=function(){var e,t,a,i,n;if(this.hasFilters){for(Filter.load(),n={},a=0,e=0;t=Filter.activeFilters[e];++e)if(t.auto&&t.boards)for(i in t.boards)n[i]||(n[i]=!0,++a);a?($.id("twPrune").className="icon rotateIcon",this.isRefreshing=!0,this.fetchCatalogs(n,a)):this.refresh()}else this.refresh()},ThreadWatcher.fetchCatalogs=function(e,t){var a,i,n,o;n={},o={count:t},a=0;for(i in e)setTimeout(ThreadWatcher.fetchCatalog,a,i,n,o),a+=200},ThreadWatcher.parseCatalogJSON=function(e){var t;try{t=JSON.parse(e)}catch(a){console.log(a),t=[]}return t},ThreadWatcher.fetchCatalog=function(e,t,a){var i;(i=new XMLHttpRequest).open("GET","//a.4cdn.org/"+e+"/catalog.json"),i.onload=function(){a.count--,t[e]=ThreadWatcher.parseCatalogJSON(this.responseText),a.count||ThreadWatcher.onCatalogsLoaded(t)},i.onerror=function(){a.count--,a.count||ThreadWatcher.onCatalogsLoaded(t)},i.send(null)},ThreadWatcher.onCatalogsLoaded=function(e){var t,a,i,n,o,s,l,r,d;$.id("twPrune").className="icon rotateIcon",this.isRefreshing=!1,d={};for(i in e)for(o=e[i],t=0;n=o[t];++t)for(s=n.threads,a=0;l=s[a];++a)r=l.no+"-"+i,this.blacklisted[r]?d[r]=1:Filter.match(l,i)&&this.addRaw(l,i);this.blacklisted=d,this.build(!0),this.refresh()},ThreadWatcher.refresh=function(){var e,t,a,i,n;if(i=$.id("watchList").children.length){e=t=0,(n=$.id("twPrune")).className="icon rotateIcon",ThreadWatcher.isRefreshing=!0,ThreadWatcher.setRefreshTimestamp();for(a in ThreadWatcher.watched)setTimeout(ThreadWatcher.fetch,t,a,++e==i?n:null),t+=200}},ThreadWatcher.onRefreshEnd=function(e){e.className="icon refreshIcon",this.isRefreshing=!1,this.save(),this.load(),this.build()},ThreadWatcher.parseThreadJSON=function(e){var t;try{t=JSON.parse(e).posts}catch(a){console.log(a),t=[]}return t},ThreadWatcher.getTrackedReplies=function(e,t){var a=null;return(a=localStorage.getItem("4chan-track-"+e+"-"+t))&&(a=JSON.parse(a)),a},ThreadWatcher.fetch=function(e,t){var a,i,n;if(n=$.id("watch-"+e),-1==ThreadWatcher.watched[e][1])return delete ThreadWatcher.watched[e],n.parentNode.removeChild(n),void(t&&ThreadWatcher.onRefreshEnd(t));a=e.split("-"),(i=new XMLHttpRequest).onload=function(){var i,n,o,s,l,r,d,c,h;if(200==this.status){for(o=ThreadWatcher.parseThreadJSON(this.responseText),s=ThreadWatcher.watched[e][1],n=0,ThreadWatcher.watched[e][4]?l=null:(l=ThreadWatcher.getTrackedReplies(a[1],a[0]))&&(r=document.createElement("div")),i=o.length-1;i>=1&&!(o[i].no<=s);i--)if(++n,l){if(r.innerHTML=o[i].com,!(d=$.cls("quotelink",r))[0])continue;for(h=0;c=d[h];++h)if(l[c.textContent]){ThreadWatcher.watched[e][4]=1,l=null;break}}n>ThreadWatcher.watched[e][2]&&(ThreadWatcher.watched[e][2]=n),o[0].archived&&(ThreadWatcher.watched[e][3]=1)}else 404==this.status&&(ThreadWatcher.watched[e][1]=-1);t&&ThreadWatcher.onRefreshEnd(t)},t&&(i.onerror=i.onload),i.open("GET","//a.4cdn.org/"+a[1]+"/thread/"+a[0]+".json"),i.send(null)},ThreadWatcher.linkToThread=function(e,t,a){return"//"+location.host+"/"+t+"/thread/"+e+(a>0?"#p"+a:"")};var Draggable={el:null,key:null,scrollX:null,scrollY:null,dx:null,dy:null,right:null,bottom:null,set:function(e){e.addEventListener("mousedown",Draggable.startDrag,!1)},unset:function(e){e.removeEventListener("mousedown",Draggable.startDrag,!1)},startDrag:function(e){var t,a,i;this.parentNode.hasAttribute("data-shiftkey")&&!e.shiftKey||(e.preventDefault(),t=Draggable,a=document.documentElement,t.el=this.parentNode,t.key=t.el.getAttribute("data-trackpos"),i=t.el.getBoundingClientRect(),t.dx=e.clientX-i.left,t.dy=e.clientY-i.top,t.right=a.clientWidth-i.width,t.bottom=a.clientHeight-i.height,"fixed"!=getComputedStyle(t.el,null).position?(t.scrollX=window.pageXOffset,t.scrollY=window.pageYOffset):t.scrollX=t.scrollY=0,t.offsetTop=FC.getDocTopOffset(),document.addEventListener("mouseup",t.endDrag,!1),document.addEventListener("mousemove",t.onDrag,!1))},endDrag:function(){document.removeEventListener("mouseup",Draggable.endDrag,!1),document.removeEventListener("mousemove",Draggable.onDrag,!1),Draggable.key&&window.Config&&(window.Config[Draggable.key]=Draggable.el.style.cssText,localStorage.setItem("4chan-settings",JSON.stringify(window.Config))),delete Draggable.el},onDrag:function(e){var t,a,i;t=e.clientX-Draggable.dx+Draggable.scrollX,a=e.clientY-Draggable.dy+Draggable.scrollY,i=Draggable.el.style,t<1?(i.left="0",i.right=""):Draggable.right<t?(i.left="",i.right="0"):(i.left=t/document.documentElement.clientWidth*100+"%",i.right=""),a<=Draggable.offsetTop?(i.top=Draggable.offsetTop+"px",i.bottom=""):Draggable.bottom<a&&Draggable.el.clientHeight<document.documentElement.clientHeight?(i.bottom="0",i.top=""):(i.top=a/document.documentElement.clientHeight*100+"%",i.bottom="")}},CustomMenu={dropDownNav:!1,classicNav:!1};CustomMenu.initCtrl=function(e,t){var a,i;CustomMenu.dropDownNav=e,CustomMenu.classicNav=t,(a=document.createElement("span")).className="custom-menu-ctrl",a.innerHTML='[<a data-cm-edit title="Edit Menu" href="#">Edit</a>]',!CustomMenu.dropDownNav||CustomMenu.classicNav||FC.hasMobileLayout?((i=$.cls("boardList"))[0]&&i[0].appendChild(a),i[1]&&i[1].appendChild(a.cloneNode(!0))):(i=$.id("boardSelectMobile").parentNode).insertBefore(a,i.lastChild)},CustomMenu.reset=function(){var e,t,a,i,n;for(a=$.cls("boardList"),i=$.cls("customBoardList"),n=$.cls("show-all-boards"),e=0;t=n[e];++e)t.removeEventListener("click",CustomMenu.reset,!1);for(e=i.length-1;t=i[e];e--)a[e].style.display=null,t.parentNode.removeChild(t)},CustomMenu.apply=function(e){var t,a,i,n,o,s,l;if(e){for(s=e.split(/[^0-9a-z]/i),(l=document.createElement("span")).className="customBoardList",t=0;n=s[t];++t)t?l.appendChild(document.createTextNode(" / ")):l.appendChild(document.createTextNode("[")),(a=document.createElement("a")).textContent=n,a.href="//boards."+$L.d(n)+"/"+n+("f"!==n?"/catalog":""),l.appendChild(a);if(l.appendChild(document.createTextNode("]")),!CustomMenu.dropDownNav||CustomMenu.classicNav||FC.hasMobileLayout){for(l.appendChild(document.createTextNode(" [")),(a=document.createElement("a")).textContent="\u2026",a.title="Show all",a.className="show-all-boards pointer",l.appendChild(a),l.appendChild(document.createTextNode("] ")),i=l.cloneNode(!0),o=$.cls("boardList"),t=0;a=o[t];++t)a.style.display="none",a.parentNode.insertBefore(t?i:l,a);for(o=$.cls("show-all-boards"),t=0;a=o[t];++t)a.addEventListener("click",CustomMenu.reset,!1)}else(a=$.cls("customBoardList")[0])&&a.parentNode.removeChild(a),(o=$.id("boardSelectMobile"))&&o.parentNode.insertBefore(l,o.nextSibling)}else!CustomMenu.dropDownNav||CustomMenu.classicNav||FC.hasMobileLayout||(a=$.cls("customBoardList")[0])&&a.parentNode.removeChild(a)},CustomMenu.onClick=function(e){var t;(t=e.target)!=document&&(t.hasAttribute("data-close")?CustomMenu.closeEditor():t.hasAttribute("data-save")&&CustomMenu.save($.id("customMenu").hasAttribute("data-standalone")))},CustomMenu.showEditor=function(e){var t,a;(t=document.createElement("div")).id="customMenu",t.className="panel",t.setAttribute("data-close","1"),!0===e&&t.setAttribute("data-standalone","1"),t.innerHTML='<div class="reply"><div class="panelHeader">Custom Board List<span class="panelCtrl"><span data-close="1" class="icon closeIcon"></span></span></div><input placeholder="Example: jp tg mu" id="customMenuBox" type="text" value=""><div class="center"><button data-save="1">Save</button></div></div>',document.body.appendChild(t),t.style.top=window.pageYOffset+(0|document.documentElement.clientHeight/2-t.offsetHeight/2)+"px",$.removeClass($.id("backdrop"),"hidden"),(a=CustomMenu.getConfig()).customMenuList&&($.id("customMenuBox").value=a.customMenuList),t.addEventListener("click",CustomMenu.onClick,!1)},CustomMenu.closeEditor=function(){var e;(e=$.id("customMenu"))&&(e.removeEventListener("click",CustomMenu.onClick,!1),document.body.removeChild(e),$.addClass($.id("backdrop"),"hidden"))},CustomMenu.save=function(e){var t,a;(t=$.id("customMenuBox"))&&!0===e&&(CustomMenu.apply(t.value),(a=CustomMenu.getConfig()).customMenu=!0,a.customMenuList=t.value,localStorage.setItem("4chan-settings",JSON.stringify(a))),CustomMenu.closeEditor()},CustomMenu.getConfig=function(){var e;return(e=localStorage.getItem("4chan-settings"))?JSON.parse(e):{}};var StickyNav={thres:5,pos:0,timeout:null,el:null,init:function(e){this.el=e?$.id("boardNavDesktop"):$.id("boardNavMobile"),$.addClass(this.el,"autohide-nav"),window.addEventListener("scroll",this.onScroll,!1)},destroy:function(e){this.el=e?$.id("boardNavDesktop"):$.id("boardNavMobile"),$.removeClass(this.el,"autohide-nav"),window.removeEventListener("scroll",this.onScroll,!1)},onScroll:function(){clearTimeout(StickyNav.timeout),StickyNav.timeout=setTimeout(StickyNav.checkScroll,50)},checkScroll:function(){var e;e=window.pageYOffset,Math.abs(StickyNav.pos-e)<=StickyNav.thres||(e<StickyNav.pos?StickyNav.el.style.top="":StickyNav.el.style.top="-"+StickyNav.el.offsetHeight+"px",StickyNav.pos=e)}};FC.panelHTML={build:function(e,t){var a;return(a=document.createElement("div")).id=e,a.className=t,a.innerHTML=FC.panelHTML[e],document.body.appendChild(a),a},theme:'<div class="panelHeader">Settings<span id="theme-close" class="icon closeIcon" title="Close"></span></div> <h4>Options</h4> <ul class="clickset"> <li class="desktop"><label><input id="theme-nobinds" type="checkbox"> Disable keybinds</label></li> <li><label><input id="theme-nospoiler" type="checkbox"> Don\'t spoiler images</label></li> <li><label><input id="theme-newtab" type="checkbox"> Open threads in a new tab</label></li> <li class="desktop"><label><input id="theme-tw" type="checkbox"> Thread Watcher</label></li> <li class="desktop"><label><input id="theme-ddn" type="checkbox"> Use drop-down navigation</label></li> </ul> <h4 class="desktop">Shortcuts</h4> <ul class="clickset desktop"> <li><kbd>R</kbd> &mdash; Refresh current page</li> <li><kbd>X</kbd> &mdash; Reorder threads</li> <li><kbd>S</kbd> &mdash; Open search box, <kbd>Esc</kbd> to close</li> <li><kbd>Shift</kbd> <kbd title="Left Mouse Button">LMB</kbd> &mdash; Hide threads</li> <li><kbd>Alt</kbd> <kbd title="Left Mouse Button">LMB</kbd> &mdash; Pin threads</li> <li><kbd title="Right Mouse Button">RMB</kbd> &mdash; Threads context menu (Firefox only)</li> </ul> <h4>Custom CSS</h4> <textarea id="theme-css" rows="4" cols="45"></textarea> <div id="theme-btns"> <span id="theme-msg"></span> <div class="center"><button id="theme-save">Save Settings</button></div> </div>',"filters-protip":'<div class="panelHeader">Filters &amp; Highlights Help<span id="filters-help-close" class="icon closeIcon" title="Close"></span></div> <h4>Patterns</h4> <ul><li><ul> <li><strong>Matching whole words:</strong></li> <li><code>feel</code> &mdash; will match <em>"feel"</em> but not <em>"feeling"</em>. This search is case-insensitive.</li> </ul></li> <li><ul> <li><strong>AND operator:</strong></li> <li><code>feel girlfriend</code> &mdash; will match <em>"feel"</em> AND <em>"girlfriend"</em> in any order.</li> </ul></li> <li><ul> <li><strong>OR operator:</strong></li> <li><code>feel|girlfriend</code> &mdash; will match <em>"feel"</em> OR <em>"girlfriend"</em>.</li> </ul></li> <li><ul> <li><strong>Mixing both operators:</strong></li> <li><code>girlfriend|boyfriend feel</code> &mdash; matches <em>"feel"</em> AND <em>"girlfriend"</em>, or <em>"feel"</em> AND <em>"boyfriend"</em>.</li> </ul></li> <li><ul> <li><strong>Exact match search:</strong></li> <li><code>"that feel when"</code> &mdash; place double quotes around the pattern to search for an exact string</li> </ul></li> <li><ul> <li><strong>Wildcards:</strong></li> <li><code>feel*</code> &mdash; matches expressions such as <em>"feel"</em>, <em>"feels"</em>, <em>"feeling"</em>, <em>"feeler"</em>, etc&hellip;</li> <li><code>idolm*ster</code> &mdash; this can match <em>"idolmaster"</em> or <em>"idolm@ster"</em>, etc&hellip;</li> </ul></li> <li><ul> <li><strong>Filtering by name or tripcode:</strong></li> <li>Prefix the pattern with <code>#</code> to search by <em>tripcode</em>: <code>#!Ep8pui8Vw2</code></li> <li>Prefix the pattern with <code>##</code> to search by <em>name</em>: <code>##Anonymous</code></li> <li>To filter by <em>capcode</em>: <code>#!#admin</code>, <code>#!#mod</code>, <code>#!#developer</code></li> </ul></li> <li><ul> <li><strong>It is also possible to filter by regular expression:</strong></li> <li><code>/^(?=.*detachable)(?=.*hats).*$/i</code> &mdash; AND operator.</li> <li><code>/^(?!.*touhou).*$/i</code> &mdash; NOT operator.</li> <li><code>/^&amp;gt;/</code> &mdash; threads starting with a quote (<em>"&gt;"</em> character as an html entity).</li> <li><code>/^$/</code> &mdash; threads with no text.</li> </ul></li> </ul> <hr> <h4>Controls</h4> <ul> <li><strong>On</strong> &mdash; enables or disables the filter.</li> <li><strong>Boards</strong> &mdash; space separated list of boards on which the filter will be active. Leave blank to apply to all boards.</li> <li><strong>Hide</strong> &mdash; hides matched threads.</li> <li><strong>Top</strong> &mdash; puts matched threads on top of the list.</li> </ul>',"filter-palette":'<div id="colorpicker" class="panel"><table id="filter-color-table"><tbody></tbody><tfoot> <tr><td>Custom</td></tr> <tr><td class="middle-txt"><input class="custom-rgb" type="text" name="custom-rgb" value="" id="filter-rgb"><span title="Select Color" id="filter-rgb-ok" class="button clickbox"></span></td></tr> <tr><td> <span class="btn-wrap"><span id="filter-palette-close" class="button">Close</span></span> <span class="btn-wrap"><span id="filter-palette-clear" class="button">Clear</span></span> </td></tr> </tfoot></table></div>',filters:'<div class="panelHeader"><input placeholder="Search" type="text" id="filters-search">Filters &amp; Highlights<span id="filters-help-open" class="icon helpIcon" title="Help"></span><span id="filters-close" class="icon closeIcon" title="Close"></span></div> <table id="filter-table"> <thead><tr> <th>Order</th> <th>On</th> <th>Pattern</th> <th>Boards</th> <th>Color</th> <th>Hide</th> <th>Top</th> <th>Del</th> <th></th> </tr></thead> <tbody id="filter-list"></tbody> <tfoot><tr><td colspan="9"> <button id="filters-add" class="left">Add</button> <span class="right"><span id="filters-msg"></span><button id="filters-save">Save</button></span> </td></tr></tfoot></table>'};var PostMenu={activeBtn:null};PostMenu.open=function(e,t,a,i,n){var o,s,l,r,d;PostMenu.activeBtn!=e?(PostMenu.close(),e.parentNode.parentNode,s='<ul><li data-report="'+t+'">Report thread</li><li data-pin="'+t+'">'+(n?"Unpin":"Pin")+' thread</li><li data-hide="'+t+'">'+(i?"Unhide":"Hide")+" thread</li>",a&&(s+='<li data-watch="'+t+'">'+(ThreadWatcher.watched[t+"-"+catalog.slug]?"Remove from":"Add to")+" watch list</li>"),(o=document.createElement("div")).id="post-menu",o.className="dd-menu",o.innerHTML=s+"</ul>",l=e.getBoundingClientRect(),o.style.top=l.bottom+3+window.pageYOffset+"px",document.addEventListener("click",PostMenu.close,!1),$.addClass(e,"menuOpen"),PostMenu.activeBtn=e,UA.dispatchEvent("4chanPostMenuReady",{postId:t,isOP:!0,node:o.firstElementChild}),document.body.appendChild(o),(r=l.left+window.pageXOffset)>(d=document.documentElement.clientWidth-o.offsetWidth)-75&&(o.className+=" dd-menu-left"),r>d&&(r=d),o.style.left=r+"px"):PostMenu.close()},PostMenu.close=function(){var e;(e=$.id("post-menu"))&&(e.parentNode.removeChild(e),document.removeEventListener("click",PostMenu.close,!1),$.removeClass(PostMenu.activeBtn,"menuOpen"),PostMenu.activeBtn=null)};