Kawiesh

[BM] Plain URL 2 Link

Jun 8th, 2020 (edited)
1,507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-----javascript---code
  2. var D=document;
  3. D.body.normalize();
  4. F(D.body);
  5.  
  6. function F(n){
  7. var u,A,M,R,c,x;
  8. if(n.nodeType==3){
  9. u=n.data.search(/https?\:\/\/[^\s]*[^.,;'">\s\)\]]/);
  10. if(u>=0) {
  11. M=n.splitText(u);
  12. R=M.splitText(RegExp.lastMatch.length);
  13. A=document.createElement("A");
  14. A.href=M.data;
  15. A.appendChild(M);
  16. R.parentNode.insertBefore(A,R);
  17. }
  18. }
  19. else if(n.tagName!="STYLE" && n.tagName!="SCRIPT" && n.tagName!="A"){
  20. for(c=0;x=n.childNodes[c];++c)F(x);
  21. }
  22. }
  23.  
  24.  
  25.  
  26.  
  27. //-----bookmarklet---version
  28. javascript:(function(){var%20D=document;%20D.body.normalize();%20F(D.body);%20function%20F(n){var%20u,A,M,R,c,x;%20if(n.nodeType==3){%20u=n.data.search(/https?\:\/\/[^\s]*[^.,;'">\s\)\]]/);%20if(u>=0)%20{%20M=n.splitText(u);%20R=M.splitText(RegExp.lastMatch.length);%20A=document.createElement("A");%20A.href=M.data;%20A.appendChild(M);%20R.parentNode.insertBefore(A,R);%20}%20}else%20if(n.tagName!="STYLE"%20&&%20n.tagName!="SCRIPT"%20&&%20n.tagName!="A")for(c=0;x=n.childNodes[c];++c)F(x);%20}%20})();
  29.  
  30.  
  31. Source: http://forums.mozillazine.org/viewtopic.php?f=38&t=1045955
Advertisement
Add Comment
Please, Sign In to add comment