Created
July 31, 2022 11:06
-
-
Save Milk-Cool/90bc180078471088bc763db0874cf9c1 to your computer and use it in GitHub Desktop.
Use <al>some text https://example.com more text</al> to automatically create links
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ALUpdate(){for(let a of document.querySelectorAll("al"))a.innerHTML=a.innerHTML.replace(/(?<!<!--autolink-->|href=")https?:\/\/(www\.)?[-a-z0-9@:%._\+~#=]{1,256}\.[a-z0-9()]{1,6}\b([-a-z0-9()@:%_\+.~#?&//=]*)/gi,'<a href="$&" target="_blank"><!--autolink-->$&</a>')}let oldContent;setInterval(()=>{oldContent!=document.body.innerHTML&&(oldContent=document.body.innerHTML,ALUpdate())}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment