[go: nahoru, domu]

Skip to content

jimmont/ifoundit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

ifoundit

iwanna search a webpage on my iphone

A bookmarklet for searching web pages, motivated by the lack of basic search on the iPhone.

javascript:void((function(){var p=window,k=document,m=k.body,j=k.createElement("form"),g;o={cAse:false,dir:1,index:0},n=(new Date).getTime();function l(b,d,i){b.addEventListener(d,i)}function c(b){j.setAttribute("style","top:"+m.scrollTop+"px;left:"+m.scrollLeft+"px;")}function h(b,d){return b.querySelectorAll(d)}o.l=h(k,"form.findonpage")[0]||false;if(o.l){return o.l.style.display="block"}j.className="findonpage";j.innerHTML="<input type=text><input type=submit class=prev value=&lt;><input type=submit class=next value=\"&gt;\"><br><input type=checkbox class=regex id=regex> <label for=regex>regex</label><input type=checkbox class=case id=cAse> <label for=cAse title=Case-Sensitive>Case</label><input type=button value=clear><input type=button value=x><style>.findonpage{z-index:99999;background:rgba(255,255,255,0.8);position:absolute;top:0;left:0;}.found_string{border-radius:5px;border:1px dotted #555;color:black !important;background:yellow !important;padding:1px;}.found_highlight{padding:3px;border:1px solid black;box-shadow:0 0 8px #555;}</style>";var a=/\bnext\b/;var e=0,q,r=h(j,"[type=submit]");while(q=r[e++]){l(q,"click",function(b){o.dir=a.test(this.className)?1:0})}m.appendChild(j);l(j,"submit",function(u){u.preventDefault();o.cAse=h(this,".case")[0].checked;function t(F){k.designMode="on";var K=p.getSelection();K.collapse(H,0);var y,x,I,H,D,C,G,E=0,J=/^(?:INPUT|TEXTAREA|text)$/i;while(p.find(F,o.cAse,0,0,0,1,1)){E++;I=K.anchorNode;y=I.parentNode;x=k.activeElement;if(!(J.test(x.nodeName)&&J.test(x.type))){H=K.focusNode;D=I==H?false:H.parentNode;G=k.defaultView.getComputedStyle(y,null).backgroundColor;k.execCommand("HiliteColor",false,"yellow");if(D){C=K.focusNode.parentNode;C.setAttribute("data-search_generated",C!=D?"true":G)}x=K.anchorNode.parentNode;x.setAttribute("data-search_generated",y!=x?"true":G)}x.className+=(" found_string search"+E);if(C){C.className+=(" found_string search"+E)}D=C=0;K.collapseToEnd()}k.designMode="off";o.max=E;o.i=o.dir?0:E-1}var z,w,f,b,s,A,v,d=h(this,"[type=text]")[0].value,B=/\b(?:found_string|search[0-9]+|found_highlight)\b/g;if(o.txt==d){o.i+=o.dir?1:-1}else{o.txt=d;f=h(k,".found_string");s=0;while(A=f[s++]){v=A.getAttribute("data-search_generated");if(v=="true"){v=k.createDocumentFragment();z=0;w=A.childNodes;while(w.length){v.appendChild(w[0])}A.parentNode.replaceChild(v,A)}else{A.style.backgroundColor=v;A.className=A.className.replace(B," ")}}m.removeChild(this);t(d);m.appendChild(this)}if(o.i>=o.max){o.i=0}else{if(o.i<0){o.i=o.max-1}}f=h(k,".search"+(o.i+1));if(f.length){s=0;v=h(k,".found_highlight");while(A=v[s++]){A.className=A.className.replace(/\bfound_highlight\b/g," ")}s=0;while(A=f[s++]){A.className+=" found_highlight"}f=f[0];z=0,w=0;while(f){z+=f.offsetLeft,w+=f.offsetTop;f=f.offsetParent}w-=this.offsetHeight;p.scrollTo(z-10,w-10)}h(j,"[type=submit]")[o.dir].focus()});q=h(j,"[type=text]")[0];q.value="flow";q.focus();l(p,"scroll",c)})());

About

iwanna search a webpage on my iphone

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published