Advertisement
LooseStool

2. expand() bookmarklet for Gab.com #SaveLocally

Jan 9th, 2019
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. javascript:(function(e,t){var r,i,n="undefined",o=t||n!=typeof window?window:{},s=function(){},l=o.console||{log:s},a=o.document||{},c=a.querySelectorAll,m=c?function(e){return c.call(a,e)}:n!=typeof m?m:n!=typeof jQuery?jQuery:s,u="object",d=(e=u!=typeof e?{name:""+(e||"")}:e,e.name||"read"),p=(l.dir=l.dir||l.log,"color:"),f=p+"red",g=p+"blue",x=p+"green",y=p+"magenta",b="\r\n",T=1e3,v=1e4,w=(n!=typeof w?w:m.trim)||function(e){return r==e?"":(e+"").replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},C=function(e){return new Date(e||Date()).toLocaleString()},h=function(e){var t,r=0;for(t in e)r++;return r},E=function(e){j.push(C()+" ["+B+"]"+e)},k=function(e){return(Math.random().toString(36)+Math.random().toString(36).slice(2)+Math.random().toString(36).slice(2)).slice(2,2+(e||99))},Q=function(e){var t=(1*new Date).toString(36);return(t+k(e)).slice(0,e)},L=function(e){return(e||location.hostname.replace(/^(?:mobile|www|m|w3|notifications)\./i,"")+".").split(".")[0].toLowerCase()},A=function(e){return{gab:{max:4,1:{label:"Load more",selectors:".post-list__load-more"},2:{label:"/|Comment ##/",selectors:"a .ion-chatbubble",verify:O},3:{label:"View more comments",selectors:".post-comment-list__loading a"},4:{label:"/Reply|Replies/",selectors:".post-comment__replies__count a"}}}[L(e)]||{}},O=function(e){var t,r=!1;try{t=e.parentElement.parentElement.parentElement.parentElement,t.getElementsByClassName&&t.getElementsByClassName("post-comments").length&&(r=!0)}catch(i){}return!r},D=function(e,t){var r=w(t),i=!e.label||("/"!=e.label.charAt(0)?r==e.label:RegExp(e.label.slice(1,-1)).test(r));return i},N=function(e){var t;e&&(t=e.hasAttribute("busyclicking"),t&&e.removeAttribute("busyclicking"))},_=function(e,t,r,i){var n,o,s=0;n=Q(14);try{e&&t&&(!D(e,r)||e.verify&&!e.verify(t)||(t.getAttribute("busyclicking")?s=2:(t.setAttribute("busyclicking","1"),o=setTimeout(function(){delete F.Q[n],N(t)},v),F.Q[n]=[e.label,t,o],s=1)))}catch(l){}return s},S=function(e,t,r){var n,o,s,a,c=F.Q.retry,m=(delete F.Q.retry,h(F.Q)),u=0;if(delete F.T,F.abort)return n=" ***ABORTED at top of poll() due to "+d+".abort="+F.abort,l.log(b+"%s LOG[%d]%c%s%c, opt=",C(),F.COUNT=++B,f,n,"",e),n+=", "+d+".it( {site: '"+e.site+"', max: "+e.max+", min: "+e.min+", retries: "+e.retries+"} )",E(n),delete F.abort;for(o in F.Q)if(s=F.Q[o],a=s[2],a&&s[1].click&&(l.log(" %cqueue click[%s]%c @ %s %s",f,o,"",C(),s[0]),s[1].click(),N(s[1]),u++,(F.CLICKED=F.CLICKED||{})[s[0]]=(F.CLICKED[s[0]]||0)+1),delete F.Q[o],!F.single)break;m&&(m=h(F.Q)),u||m?(l.log("%s clicked(%s) or L>0(%s), so setTimeout%d poll(opt[retries=%s], %d)",C(),u,m,14,e.retries,m),delete e.retries,F.Q.retry=["retry",{}],F.T||(F.T=setTimeout(function(){S(e,m,r)},14))):c||e.retries?(i=v/r,e.retries=c?F.retries||i:e.retries-1,l.log("%s not clicked and L=0, BUT will retry: setTimeout%d it(opt[%cretries=%d%c])",C(),r,x,e.retries,""),F.T||(F.T=setTimeout(function(){delete F.T,U(e)},r))):l.log("%s poll completed without clicking and will not retry.",C())},F=o[d]||function(e){var t=(e=F.nextpage(e,!0)).min;return e.max=F.expand(e,!0).max,e.min=t,F.it(e,!0)},U=function(t,i){var n,o,s,a,c,p,w=(t=u!=typeof t?{site:""+(t||"")}:t,L(t.site||e.site)),h=(t.site=e.site=w,A(w)||{}),k=t.delay||e.delay||T,Q=d+".it()",O=0,D=0,N="";for(t.min=r!=t.min?t.min||F.min||1:0,t.max=r!=t.max?t.max||F.max||0:0,t.max=(t.max&&!h[t.max]?h.max:t.max)||0,t.min=h.max?(t.min&&!h[t.min]?1:t.min)||0:0,Q=Q.replace("()","( {site: '"+t.site+"', max: "+t.max+", min: "+t.min+"} )"),(r==t.retries||i)&&(l.log(b+"%s LOG[%d] start %c%s%c, opt=",C(),F.COUNT=++B,x,Q,"",t),E(" START "+Q)),n=t.min;n<=t.max;n++){props=h[n]||{};try{s=m(props.selectors)}catch(U){}if(a=(s||[]).length,o=0,l.log(">element loop top @ %s, levels[%d] label=%c%s%c, selectors=%c%s%c, found=%c%d%c",C(),n,g,props.label,"",y,props.selectors,"",g,a,""),a){for(c=0;a>c;c++)add=_(props,p=s[c],p.textContent,k),1==add?o++:2==add&&D++;O+=o,l.log("^element loop btm @ %s, added to queue %c%d out of %d%c",C(),x,o,a,"")}}return t.retries||delete t.retries,O||t.retries?(O||(N=" (but opt.retries="+t.retries+")"),l.log("Timeout clearing and restarting poll(opt, clickcount=%d) because %cfound %d new%s%c",O,f,O,N,""),F.T&&clearTimeout(F.T),F.T=setTimeout(function(){S(t,O,k)},14)):(D&&(N=" (after skipping elements x"+D+" due to 'busyclicking=1' -- reset after "+v/1e3+" seconds)"),l.log(b+">>> Timeout unchanged. After all retries completed, %cfound 0 new%c%s%c.",f,y,N,""),l.log(b+"%s LOG[%d] ended %c%s%c, opt=",C(),F.COUNT=++B,x,Q,"",t),E(" ENDED "+Q)),F},G=function(t,r){var t=u!=typeof t?{site:""+(t||"")}:t,n=L(t.site||e.site),o=(t.site=e.site=n,A(n)||{}),s=t.delay||e.delay||T;return t.max=t.min=1,o[t.min]||(t.min=t.max=0),o[t.max]||(t.max=t.min),i=2*v/s,t.retries=t.retries||i,r?t:U(t,!0)},R=function(t,r){var t=u!=typeof t?{site:""+(t||"")}:t,n=L(t.site||e.site),o=(t.site=e.site=n,A(n)||{}),s=t.delay||e.delay||T;return t.max=4,t.min=2,o[t.min]||(t.min=t.max=o.max),o[t.max]||(t.max=o.max),i=2*v/s,t.retries=t.retries||i,r?t:U(t,!0)},B=F.COUNT=F.COUNT||0,j=(F.it=U,F.nextpage=G,F.expand=R,F.Q=F.Q||[],F.LOG=F.LOG||[]);return o[d]=F})("read").expand();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement