Skip to content

Instantly share code, notes, and snippets.

@noaione
Created September 22, 2023 01:41
Show Gist options
  • Save noaione/e4d721fe1635dbd316a5ae0908a3b354 to your computer and use it in GitHub Desktop.
Save noaione/e4d721fe1635dbd316a5ae0908a3b354 to your computer and use it in GitHub Desktop.
books storefront cover ripping scriplet as a browser bookmark. Most of the time it open a new tab because I'm retarded.
javascript:void%20function(){function%20t(t,n){const%20e=t%20instanceof%20Blob,r=e%3FURL.createObjectURL(t):t,o=document.createElement(%22a%22);o.href=r,o.download=n,o.target=%22_blank%22,o.rel=%22noopener%20noreferrer%22,o.dispatchEvent(new%20MouseEvent(%22click%22)),e%26%26URL.revokeObjectURL(r)}var%20n=Uint8Array,e=Uint16Array,r=Uint32Array,o=new%20n([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),i=new%20n([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),a=function(t,n){for(var%20o=new%20e(31),i=0;i%3C31;++i)o[i]=n+=1%3C%3Ct[i-1];var%20a=new%20r(o[30]);for(i=1;i%3C30;++i)for(var%20c=o[i];c%3Co[i+1];++c)a[c]=c-o[i]%3C%3C5|i;return[o,a]},c=a(o,2),l=c[0],s=c[1];l[28]=258,s[258]=28,a(i,0);for(var%20h=new%20e(32768),f=0;f%3C32768;++f){var%20u=(43690%26f)%3E%3E%3E1|(21845%26f)%3C%3C1;u=(61680%26(u=(52428%26u)%3E%3E%3E2|(13107%26u)%3C%3C2))%3E%3E%3E4|(3855%26u)%3C%3C4,h[f]=((65280%26u)%3E%3E%3E8|(255%26u)%3C%3C8)%3E%3E%3E1}var%20d=new%20n(288);for(f=0;f%3C144;++f)d[f]=8;for(f=144;f%3C256;++f)d[f]=9;for(f=256;f%3C280;++f)d[f]=7;for(f=280;f%3C288;++f)d[f]=8;var%20v=new%20n(32);for(f=0;f%3C32;++f)v[f]=5;var%20g=[%22unexpected%20EOF%22,%22invalid%20block%20type%22,%22invalid%20length/literal%22,%22invalid%20distance%22,%22stream%20finished%22,%22no%20stream%20handler%22,,%22no%20callback%22,%22invalid%20UTF-8%20data%22,%22extra%20field%20too%20long%22,%22date%20not%20in%20range%201980-2099%22,%22filename%20too%20long%22,%22stream%20finishing%22,%22invalid%20zip%20data%22],p=function(t,n,e){var%20r=new%20Error(n||g[t]);if(r.code=t,Error.captureStackTrace%26%26Error.captureStackTrace(r,p),!e)throw%20r;return%20r},w=new%20n(0),m=function(){for(var%20t=new%20Int32Array(256),n=0;n%3C256;++n){for(var%20e=n,r=9;--r;)e=(1%26e%26%26-306674912)^e%3E%3E%3E1;t[n]=e}return%20t}(),y=function(t,n,e){for(;e;++n)t[n]=e,e%3E%3E%3E=8},E=%22undefined%22!=typeof%20TextEncoder%26%26new%20TextEncoder,A=%22undefined%22!=typeof%20TextDecoder%26%26new%20TextDecoder;try{A.decode(w,{stream:!0}),1}catch(t){}function%20z(t,o){if(o){for(var%20i=new%20n(t.length),a=0;a%3Ct.length;++a)i[a]=t.charCodeAt(a);return%20i}if(E)return%20E.encode(t);var%20c=t.length,l=new%20n(t.length+(t.length%3E%3E1)),s=0,h=function(t){l[s++]=t};for(a=0;a%3Cc;++a){if(s+5%3El.length){var%20f=new%20n(s+8+(c-a%3C%3C1));f.set(l),l=f}var%20u=t.charCodeAt(a);u%3C128||o%3Fh(u):u%3C2048%3F(h(192|u%3E%3E6),h(128|63%26u)):u%3E55295%26%26u%3C57344%3F(h(240|(u=65536+(1047552%26u)|1023%26t.charCodeAt(++a))%3E%3E18),h(128|u%3E%3E12%2663),h(128|u%3E%3E6%2663),h(128|63%26u)):(h(224|u%3E%3E12),h(128|u%3E%3E6%2663),h(128|63%26u))}return%20function(t,o,i){(null==o||o%3C0)%26%26(o=0),(null==i||i%3Et.length)%26%26(i=t.length);var%20a=new(2==t.BYTES_PER_ELEMENT%3Fe:4==t.BYTES_PER_ELEMENT%3Fr:n)(i-o);return%20a.set(t.subarray(o,i)),a}(l,0,s)}var%20b=function(t){var%20n=0;if(t)for(var%20e%20in%20t){var%20r=t[e].length;r%3E65535%26%26p(9),n+=r+4}return%20n},T=function(t,n,e,r,o,i,a,c){var%20l=r.length,s=e.extra,h=c%26%26c.length,f=b(s);y(t,n,null!=a%3F33639248:67324752),n+=4,null!=a%26%26(t[n++]=20,t[n++]=e.os),t[n]=20,n+=2,t[n++]=e.flag%3C%3C1|(i%3C0%26%268),t[n++]=o%26%268,t[n++]=255%26e.compression,t[n++]=e.compression%3E%3E8;var%20u=new%20Date(null==e.mtime%3FDate.now():e.mtime),d=u.getFullYear()-1980;if((d%3C0||d%3E119)%26%26p(10),y(t,n,d%3C%3C25|u.getMonth()+1%3C%3C21|u.getDate()%3C%3C16|u.getHours()%3C%3C11|u.getMinutes()%3C%3C5|u.getSeconds()%3E%3E%3E1),n+=4,-1!=i%26%26(y(t,n,e.crc),y(t,n+4,i%3C0%3F-i-2:i),y(t,n+8,e.size)),y(t,n+12,l),y(t,n+14,f),n+=16,null!=a%26%26(y(t,n,h),y(t,n+6,e.attrs),y(t,n+10,a),n+=14),t.set(r,n),n+=l,f)for(var%20v%20in%20s){var%20g=s[v],w=g.length;y(t,n,+v),y(t,n+2,w),t.set(g,n+4),n+=4+w}return%20h%26%26(t.set(c,n),n+=h),n},x=function(){function%20t(t){var%20n;this.filename=t,this.c=(n=-1,{p:function(t){for(var%20e=n,r=0;r%3Ct.length;++r)e=m[255%26e^t[r]]^e%3E%3E%3E8;n=e},d:function(){return~n}}),this.size=0,this.compression=0}return%20t.prototype.process=function(t,n){this.ondata(null,t,n)},t.prototype.push=function(t,n){this.ondata||p(5),this.c.p(t),this.size+=t.length,n%26%26(this.crc=this.c.d()),this.process(t,n||!1)},t}(),k=function(){function%20t(t){this.ondata=t,this.u=[],this.d=1}return%20t.prototype.add=function(t){var%20e=this;if(this.ondata||p(5),2%26this.d)this.ondata(p(4+8*(1%26this.d),0,1),null,!1);else{var%20r=z(t.filename),o=r.length,i=t.comment,a=i%26%26z(i),c=o!=t.filename.length||a%26%26i.length!=a.length,l=o+b(t.extra)+30;o%3E65535%26%26this.ondata(p(11,0,1),null,!1);var%20s=new%20n(l);T(s,0,t,r,c,-1);var%20h=[s],f=function(){for(var%20t=0,n=h;t%3Cn.length;t++){var%20r=n[t];e.ondata(null,r,!1)}h=[]},u=this.d;this.d=0;var%20d=this.u.length,v=function(t,n){var%20e={};for(var%20r%20in%20t)e[r]=t[r];for(var%20r%20in%20n)e[r]=n[r];return%20e}(t,{f:r,u:c,o:a,t:function(){t.terminate%26%26t.terminate()},r:function(){if(f(),u){var%20t=e.u[d+1];t%3Ft.r():e.d=1}u=1}}),g=0;t.ondata=function(r,o,i){if(r)e.ondata(r,o,i),e.terminate();else%20if(g+=o.length,h.push(o),i){var%20a=new%20n(16);y(a,0,134695760),y(a,4,t.crc),y(a,8,g),y(a,12,t.size),h.push(a),v.c=g,v.b=l+g+16,v.crc=t.crc,v.size=t.size,u%26%26v.r(),u=1}else%20u%26%26f()},this.u.push(v)}},t.prototype.end=function(){var%20t=this;2%26this.d%3Fthis.ondata(p(4+8*(1%26this.d),0,1),null,!0):(this.d%3Fthis.e():this.u.push({r:function(){1%26t.d%26%26(t.u.splice(-1,1),t.e())},t:function(){}}),this.d=3)},t.prototype.e=function(){for(var%20t=0,e=0,r=0,o=0,i=this.u;o%3Ci.length;o++){r+=46+(v=i[o]).f.length+b(v.extra)+(v.o%3Fv.o.length:0)}for(var%20a,c,l,s,h,f=new%20n(r+22),u=0,d=this.u;u%3Cd.length;u++){var%20v=d[u];T(f,t,v,v.f,v.u,-v.c-2,e,v.o),t+=46+v.f.length+b(v.extra)+(v.o%3Fv.o.length:0),e+=v.b}a=f,c=t,l=this.u.length,s=r,h=e,y(a,c,101010256),y(a,c+8,l),y(a,c+10,l),y(a,c+12,s),y(a,c+16,h),this.ondata(null,f,!0),this.d=2},t.prototype.terminate=function(){for(var%20t=0,n=this.u;t%3Cn.length;t++){n[t].t()}this.d=2},t}();(function(){if(!/www.amazon.*/.test(window.location.hostname))return;const%20n=document.querySelectorAll(%22.itemImageLink%22),e=t=%3Efunction(t,n,e=0){const%20r=t.match(n);if(r%26%26r[e])return%20r[e]}(t,/(%3F:[/dp]|$)([A-Z0-9]{10})/,1),r=t=%3E`https://${window.location.hostname}/images/P/${t}.01.MAIN._SCRM_.jpg`;if(n.length%3E0){const%20o=Array.from(n).map((t=%3Ee(t.href)));return%20n.length%3E4%26%26confirm(%22Since%20you're%20downloading%20more%20than%204%20covers,%20would%20you%20like%20to%20zip%20them%3F%22)%3Ffunction(e){const%20o=[],i=new%20k(((n,e,r)=%3E{n%3Falert(%22Failed%20to%20zip%20covers!%22):o.push(e),r%26%26t(new%20Blob(o,{type:%22application/zip%22}),%22covers.zip%22)}));e.forEach((t=%3E{if(!t)return;c(r(t),t)}));let%20a=0;function%20c(t,e){const%20r=new%20FileReader;r.onload=t=%3E{if(!t.target)return++a;const%20r=new%20Uint8Array(t.target.result),o=new%20x(`${e}.jpg`);i.add(o),o.push(r,!0),++a,a%3E=n.length%26%26i.end()},fetch(t).then((t=%3Et.blob())).then((t=%3E{try{r.readAsArrayBuffer(t)}catch(t){console.error(%22Failed%20to%20zip%20cover!%22,t)}})).catch((t=%3Econsole.error(%22Failed%20to%20fetch%20cover!%22,t)))}}(o):void%20i(o)}const%20o=e(window.location.href);if(!o)return%20alert(%22No%20covers%20found%20on%20this%20page!%22);function%20i(n){n.forEach((n=%3E{n%26%26t(r(n),`${n}.jpg`)}))}i([o])})();}();
javascript:(function()%7Bfunction%20f(c%2Ca)%7Bvar%20b%3Ddocument.createElement(%22a%22)%3Bb.href%3Da%3Bb.download%3Dc%3Bb.target%3D%22_blank%22%3Bb.rel%3D%22noopener%20noreferrer%22%3Bb.dispatchEvent(new%20MouseEvent(%22click%22))%7Dfunction%20h(c)%7Bvar%20a%3Ddocument.createElement(%22a%22)%3Ba.href%3Dc%3Breturn%20window.location.hostname%3D%3D%3Da.hostname%26%26window.location.protocol%3D%3D%3Da.protocol%7Dvar%20d%3Ddocument.querySelector(%22.we-book-artwork__lighting%22).querySelector(%22picture%22).querySelector(%22source%5Btype%3D'image%2Fjpeg'%5D%22).getAttribute(%22srcset%22).split(%22%2C%22)%5B0%5D.split(%22%20%22)%5B0%5D.trim().replace(%2F(%5Cd%2B)x0w%5C.jpg%2F%2C%222400x0w.jpg%22)%2Cg%3Ddocument.querySelector(%22meta%5Bname%3D'apple%3Acontent_id'%5D%22)%2Ce%3D%22cover.jpg%22%3Bg%26%26(e%3Dg.getAttribute(%22content%22)%2B%22.jpg%22)%3B-1%3D%3D(navigator.userAgent%7C%7C%22%22).indexOf(%22Firefox%2F%22)%7C%7Ch(d)%3Ff(e%2Cd)%3AsetTimeout(f.bind(null%2Ce%2Cd)%2C1E2)%7D)()%3Bvoid+0
javascript:(function()%7Bfunction%20downloadImage(b%2C%20a)%20%7Bvar%20d%20%3D%20document.createElement(%22a%22)%3Bd.style.display%20%3D%20%22none%22%3Bd.href%20%3D%20b%3Bd.download%20%3D%20a%3Bd.dispatchEvent(new%20MouseEvent('click'))%3B%7Dfunction%20noop()%20%7B%7Dfunction%20getBookImage()%20%7Bvar%20b%20%3D%20function%20(c)%20%7Breturn%20%22undefined%22%20%3D%3D%3D%20typeof%20c%20%7C%7C%20null%20%3D%3D%3D%20c%7D%2Ca%20%3D%20document.querySelector(%22.book-img%22)%3Bif%20(b(a)%20%26%26%20(a%20%3D%20document.querySelector(%22.m-thumb__image%22)%2C%20b(a)))%20%7Balert(%22Unable%20to%20find%20any%20cover%20here!%22)%3Breturn%7Da%20%3D%20a.querySelector(%22img%22)%3Bb(a)%20%3F%20alert(%22Unable%20to%20find%20any%20cover%20here!%20(Image%20target%20not%20found)%22)%20%3A%20(a%20%3D%20a.getAttribute(%22src%22)%2C%20b(a)%20%7C%7C%20%22%22%20%3D%3D%3D%20a%20%3F%20alert(%22Unable%20to%20find%20any%20cover%20here!%20(No%20image%20source%20found)%22)%20%3A%20(a%20%3D%20a.match(%2Fhttps%3A%5C%2F%5C%2Frimg%5C.bookwalker%5C.jp%5C%2F(%5B%5Cd%5D%2B)%5C%2F.*%2F)%2C%20b(a)%20%3F%20alert(%22Unable%20to%20find%20any%20cover%20here!%20(Invalid%20source%20thumbnail)%22)%20%3A%20(a%20%3D%20a%5B1%5D%2C%20b(a)%20%3F%20alert(%22Unable%20to%20find%20any%20cover%20here!%20(No%20cover%20ID%20found)%22)%20%3A%20(console.log(%22%5BBookwalker%20Cover%5D%20Getting%20%22%20%2B%20a)%2C%20b%20%3D%20parseInt(a.toString().split(%22%22).reverse().join(%22%22))%20-%201%2C%20a%20%3D%20%22http%3A%2F%2Fc.bookwalker.jp%2FcoverImage_%22%20%2B%20b.toString()%20%2B%20%22.jpg%22%2C%20console.log(a)%2C%20downloadImage(a%2C%20%22coverImage_%22%20%2B%20b.toString()%20%2B%20%22.jpg%22)))))%7D%3BgetBookImage()%7D)()
javascript:%22use%20strict%22;void%20function(){const%20b=a=%3Enull===a||a===void%200;(function(){const%20c=window.location.hostname;if(!c.includes(%22kobo%22))return%20void%20alert(%22Not%20Kobo.com%20page!%22);const%20d=document.querySelector(%22div[data-kobo-gizmo='ItemDetailActions']%22);if(b(d))return%20void%20alert(%22Unable%20to%20find%20item%20element!%22);const%20e=d.querySelector(%22img%22);if(b(e))return%20void%20alert(%22Unable%20to%20find%20image%20element!%22);const%20f=e.src,g=f.split(%22/%22),h=f.split(%22/%22,4)[3],i=g[g.length-1],j=document.createElement(%22a%22);j.download=i,j.href=`https://kbimages1-a.akamaihd.net/${h}/${i}`,j.dispatchEvent(new%20MouseEvent(%22click%22))})()}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment