Kawiesh

Find links... experiment n linkefy

May 16th, 2021 (edited)
339
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //just a skeleton, will clean & fine-tune it later
  2.  
  3.  
  4. let a= window.open(),
  5.     b= document.links,
  6.     c= [],
  7.     d= "<br><br>";
  8.  
  9. [...b].forEach(i=>{
  10. c.push(i.outerHTML);
  11. })
  12.  
  13. a.document.write(`<html>
  14. <head>
  15. <title> Links on ${location.hostname}</title>
  16. <style>
  17. html,body{position: absolute;
  18. left:0; right:0; top:0; bottom:0;
  19. display:flex; flex-direction:column;
  20. justify-content:flex-start;
  21. align-items: center;
  22. background:black;
  23. color: gray;
  24. }
  25. #container{
  26. padding:10px;
  27. border: 5px double gray;
  28. }
  29. a{color: white; margin-bottom:2em;}
  30. </style>
  31. </head>
  32. <body>
  33. <span> List of links on ${location.hostname}</span>
  34. <br>
  35. <div id="container">
  36. ${c.join(d)}
  37. </div>
  38. </body></html>
  39.  
  40. `);
  41.  
  42.  
  43.  
  44. //------------LINKEFY----
  45.  
  46.  
  47. let a= /(?:https?:\/\/)?([\w-]+\.)?[\w-]+\.\w+(\/\S+)?/gi;
  48. let b= document.body.innerHTML.match(a);
  49.  
  50. b.forEach(i=>{
  51. document.body.innerHTML=
  52. document.body.innerHTML
  53. .split(i)
  54. .join(`<a href="${i}">${i}</a>`);
  55. });
  56.  
  57.  
Add Comment
Please, Sign In to add comment