Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //run this on a web.archive.org page
- //new version: https://tinyurl.com/waybackapi
- /*
- (the page can itself be an iframe created by javascript that has src set to a web.archive.org/web/[datenumber]im_/https://yourwebsite.com/archire_org_api.html page that has postMessage capabilities to receive and respond to javscript archive requests.
- */
- var ifr1=document.getElementById("ifr1"),
- frm2=document.getElementById("spn-form"),
- frm_u=frm2.querySelector("input[type=text]"),
- xhr=new XMLHttpRequest(),
- xhrbr=0,
- qry=location.search.substr(1).split("&"),qi=qry.length,torg,b;
- while(qi--){ b=qry[qi].indexOf("="); if(qry[qi].substr(0,b)=="torg") torg=qry.substr(b+1); }
- document.getElementById("orgb").innerText=location.origin;
- xhr.onload=function xhrL0(){
- if(xhr.readyState!=4){
- xhrbr++;
- if(xhrbr<150)setTimeout(xhrL0,2000);
- return 0;
- }else{
- xhrbr=0;
- self.parent.postMessage({"type":"fetchresult","response":xhr.response,"url":xhr.responseURL},torg);
- }
- };
- var savedURL=function(url){
- return url.substr(url.indexOf("http",4));
- };
- getContentLinks=function(){
- var non,rel=[],as=ifr1.contentDocument.querySelectorAll("a");
- while(i--){ non=as[i].href.indexOf("/web/"); if(non+1&&(as[i].href.indexOf("/http",non)+1)) rel.push(as[i].href); }
- var rsc=ifr1.contentDocument.getElementById("spn-resources");
- if(rsc&&rsc.value.length>7){ rel=rel.concat(rsc.value.split("\n")); }
- return rel;
- };
- var ifr_l0d=function(){
- var ti1=ifr1.contentDocument.getElementById("spn-result"),oes=HTMLElement.prototype.__lookupSetter__("innerHTML");
- ti1.__defineSetter__("innerHTML",function(){ oes.apply(this,arguments);
- //has loaded?
- var cont=getContentLinks();
- self.parent.postMessage({"type":"saveresult","links":cont},torg);
- });
- ti1.__defineGetter__("innerHTML",HTMLElement.prototype.__lookupGetter__("innerHTML"));
- };
- ifr1.addEventListener("load",ifr_l0d);
- var omsg=function(e){
- if(!torg)torg=e.origin;
- var dat=e.data,opr=dat.opr;
- if(opr=="savepage"){
- if(frm_u=dat.url) frm2.submit();
- }
- else if(opr=="fetch"){
- if(dat.url){
- xhr.open("GET",dat.url);
- //https://web.archive.org/cdx/?url=r5---sn-a5mekn7d.googlevideo.com/*&limit=100&filter=mimetype:video/mp4&filter=url:.*AOq0QJ8wRgIhAI6WhGhZqezkzZQbgdiQl5JOWF8R7.*
- xhr.responseType=dat.responseType||"text";
- xhr.send();
- }
- }
- };
- self.addEventListener("onmessage",omsg);
- //saved in-page content links
- //self.lal_=ifr1.contentDocument.querySelectorAll("textarea")[0].value; self.in_page_content=lal_.split("\n");
- //frm2.querySelectorAll("input[type=text]")
- /*
- //form copy
- self.forms=ifr1.contentDocument.getElementsByTagName("form");
- self.i=forms.length; self.rf_=[]; while(i--){ if(forms[i].getAttribute("action")=="/save") rf_.push(forms[i]); }
- self.frm_0=rf_[0];
- self.frm2=frm_0.cloneNode();
- frm2.innerHTML=frm_0.innerHTML;
- frm2.target="ifr1";
- //frm2.querySelectorAll("input[name=capture_outlinks]")[0].checked=!0; //do capture outlinks?
- frm2.querySelectorAll("input[name=capture_all]")[0].checked=!1; //don't save error pages
- */
Add Comment
Please, Sign In to add comment