IWBH_01

javascript crawl (can help preform syntax highlighting)

Apr 29th, 2021 (edited)
1,010
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //note end bracket/brace/parenth character indexes are index Of that end character not index after
  3. self.JScrawl={
  4.  
  5. "XrakScrps":function(hs,gd){var T=this,d=document,db=document.body,ifr=T.ifr1||(T.ifr1=d.createElement("iframe")),Hdoc;
  6.   db.appendChild(ifr);Hdoc=ifr.contentDocument;db.removeChild(ifr);
  7.   Hdoc.documentElement.innerHTML=hs;
  8.   return gd?Hdoc:Hdoc.getElementsByTagName("script");
  9. },
  10.  
  11.  
  12. "jsp_":function javascript_parse_string(js){
  13. var i=0,
  14. lev=[],ins,em={"(":")","[":"]","{":"}"}, //lev = bracket level, em=end bracket map
  15. AM=[], //all map
  16. bm=[],cl=0,lc=0, //bm = bracket map [bracketChar, AbsoluteIndex, MatchingBracketAbsoluteIndex,IndexOfMatchingBracketInBmArray]; cl=current line; lc=line character (current character index on line)
  17. Lm={"(":[],"[":[],"{":[]}, //Last match (bracket)
  18. sm=[],nl=[], //string map [denoterChar,AbsoluteIndex,AbsoluteEndIndex], nl=new line array
  19. evs=":?&|*^-+<>!",ev=1,rf="gimsuy",rm=[],inR, //expecting value string;ev = expecting value (not literal number) rather any value, after : or , or = or [ or "(" a value is expected; a "value" can be anything besides whitespace ? Right now this is just to determine if '/' has the context of division or regex; rm=RegEx map; inR = in RegEx;
  20. inC,cm=[], //inC= in comment, cm= comment map [denoteType,AbsoluteIndex,AbsoluteEndIndex]
  21. stmnt=["case","class","const","break","delete","do","else","export","for","function","import","in","let","new","of","return","switch","this","throw","var","while","with","yield"],
  22. stmtR=new RegExp(stmnt.join("|")),
  23. a_z=/[a-zA-Z]/,Var=/[a-zA-Z_$]/,num=/[0-9]/,hex=/[0-9a-fA-F]/,
  24. nm=[], //Number Map
  25. vm=[], //Var Map
  26. smm=[], //StateMent Map
  27. B,b,ws="\t \xA0\f\v",Lnw; //B & b=buffer (generic temp storage), ws= whitespace, Lnw = Last non-whitespace
  28. while(i<js.length){
  29.  let c=js[i];
  30.  if(ws.indexOf(c)+1){ //white space
  31.   if(js[i-1]=="/"){ev=1;}
  32.  }else if(ins){ //in string
  33.   if(c==ins&&js[i-1]!="\x5C"){ ins=!1; sm[sm.length-1][2]=i+1; }
  34.  }else if(inR){ //in RegEx in regex (/) like in string and differentiate it from division operator by weather a value has come before it?
  35.   if(inR==1){
  36.    if(c=="/"&&js[i-1]!="\x5C"){ if(rf.indexOf(js[i+1])+1){ inR=2; }else{ inR=!1; rm[rm.length-1][1]=i+1; } }
  37.   }else if(inR==2){ if(rf.indexOf(js[i+1])<0){ inR=!1; rm[rm.length-1][1]=i+1; } }
  38.  }else if(inC){ //in Comment
  39.   if((inC=="//"&&(c=="\r"||c=="\n"))||(inC=="/*"&&c=="/"&&js[i-1]=="*")){inC=!1;cm[cm.length-1][2]=i+1;}
  40.  }else{
  41.   if(c=="\n"||(c=="\r"&&js[i+1]!="\n")){ nl.push(i); AM.push(["nl",i]); }
  42.   else{
  43.    if(c=="/"){
  44.     if((B=c[i+1])==c){ cm.push(b=["//",i]); inC="//"; AM.push(["cm",b]); }
  45.     else if(B=="*"){ cm.push(b=["/*",i]); inC="/*"; AM.push(["cm",b]); }
  46.     else if(ev){ inR=1; rm.push(b=[i]); AM.push(["rm",b]); }
  47.    }
  48.    else if(c==";"){ ev=1; }
  49.    else if(evs.indexOf(c)+1){ ev=1; }
  50.    else if((c=='"'||c=="'")){sm.push(b=[ins=c,i]); AM.push(["sm",b]);}
  51.    else if(c=="("||c=="["||c=="{"){lev.push(c); Lm[c].push(bm.push(b=[c,i])-1); AM.push(["bm",b]); ev=1; }
  52.    else if(lev.length&&c==em[lev[lev.length-1]]){ let m=Lm[lev.pop()].pop(); (B=bm[m])[2]=i;B[3]=bm.push(b=[c,i,bm[m][1],m])-1; AM.push(["bm",b]); ev=0; }
  53.    else if(num.test(c)){ ev=0; nm.push(b=[i]); AM.push(["nm",b]); let T=num,o=1; if(c=="0"&&js[i+1]=="x"){o++;T=hex;} while(T.test(js[i+o]))o++; b[1]=i+o;  i+=(o-1);/*Number*/ }
  54.    else if(Var.test(c)){ //var and statement
  55.     let o=1; while(Var.test(B=js[i+o])||num.test(B))o++; let T,p=js[Lnw]==".",cv=js.substr(i,o);
  56.     b=[i,i+o];
  57.     if((!p)&&stmtR.test(cv)){ T="smm"; smm.push(b);  }
  58.     else{ T="vm"; vm.push(b); if(p)b[2]=!0; }
  59.     AM.push([T,b]);
  60.     i+=(o-1);
  61.    }
  62.    Lnw=i;
  63.   }
  64.  }
  65.  i++;
  66. }
  67. return {"raw":js,"bm":bm,"sm":sm,"nl":nl,"cm":cm,"rm":rm,"nm":nm,"vm":vm,"smm":smm,"AM":AM};
  68. },
  69.  
  70.  
  71. "XtrkJSON":function(jspo){
  72. var jsna=[],js=jspo.raw,Rs="";
  73. for(let V of jspo.bm){ if(V[0]=="{"){
  74.   let R=js.substring(V[1],V[2]+1),jo;
  75.   try{ if(V[2]-V[1]>3&&Rs.indexOf(R)<0){ jo=JSON.parse(R); Rs+=(";\r\n\r\n"+R); jsna.push([V,jo]); } }catch(e){}
  76. } }
  77.  
  78. return jsna;
  79. }
  80.  
  81. };
  82.  
  83.  
  84. //&nbsp; = 0xA0 =
  85.  
  86.  
  87.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×