Skip to content

Instantly share code, notes, and snippets.

@pastak
Last active October 5, 2015 09:57
Show Gist options
  • Save pastak/2789334 to your computer and use it in GitHub Desktop.
Save pastak/2789334 to your computer and use it in GitHub Desktop.
(function(){var i,p,t,v,e,vd,pa=n=z=0,npc,np,xrh,d=document,imgView='<div style="width:100%;">',a=d.getElementById("article-contents"),imgs=a.getElementsByTagName("img"),Bimgs=[],m= /livedoor.blogimg.jp/ , m2= /livedoor.sp.blogimg.jp/ , gI=function(){for (i in imgs){p=imgs[i].parentNode;if(typeof p==="object"){if(m.test(p.href)){Bimgs[n]=p.href;}else if(m2.test(imgs[i].src)){t=imgs[i].src;t=t.replace("livedoor.sp.blogimg.jp","livedoor.blogimg.jp");t=t.replace("-s.",".");Bimgs[n]=t;}imgView+=("<img id='"+n+"'style='display:none;' src='"+Bimgs[n++]+"' />")}}npc=np=null;npc=d.getElementsByClassName("pagingNav");np=npc[z];if(np){xhr=new XMLHttpRequest();xhr.open("GET",np.href,false);xhr.onreadystatechange = function(){if(xhr.readyState==4){t=xhr.responseText;e=document.createElement("div");e.innerHTML=t;a=e.querySelector("#article-contents");imgs=a.getElementsByTagName("img");d=a.parentNode;z=1;gI()}};xhr.send(null);}};gI();imgView+=("<input type='button' style='width:40%;height:auto; font-size:2em; font-weight:bold; float:left;' value='<<' onclick='window.PImg()' />"+"<span style='margin:auto;width:5%;font-size:auto;' id='page'></span>"+"<input type='button' style='width:40%;height:auto;font-size:2em; font-weight:bold;float:right;' value='>>' onclick='window.NImg()' />"+"</div>");n=n-1;v=window.open("about:blank",null);vd=v.document;vd.onload=function(){if(document.body.scrollTop==0){ setTimeout(function(){scrollTo(0,1)},1);}};v.n=0;v.PImg=function(){if(v.n>0){var i=vd.getElementsByTagName("img");i[v.n].style.display="none"; i[--v.n].style.display="block";vd.getElementById("page").innerHTML=((v.n+1)+"/"+(n+1))}else{alert("this is first")}};v.NImg=function(){if(v.n!==n){var i=vd.getElementsByTagName("img");i[v.n].style.display="none";i[++v.n].style.display="block";vd.getElementById("page").innerHTML=((v.n+1)+"/"+(n+1))}else{alert("this is last")}};vd.body.innerHTML=imgView;vd.i=vd.getElementsByTagName("img");vd.i[0].style.display="block";})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment