- http://www.google.com/
- https://www.google.com/
- ttp://example.com/~pages/pa-ge/?param=foo+bar
- ttp://beben-koben.blogspot.com/2014/05/selection-good-resources-may-2014.html
- https://www.google.com/search?q=tutorial
<script type='text/javascript'>
//<![CDATA[
document.addEventListener("DOMContentLoaded",function(){for(var t=document.evaluate('descendant::text()[contains(self::text(),"ttp") and not(ancestor::a) and not(ancestor::textarea) and not(ancestor::script) and not(ancestor::style)]',document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null),e=0;e<t.snapshotLength;e++){var n=t.snapshotItem(e);n.textContent.match(/h?ttps?:\/\/[a-zA-Z0-9\.\/\-_~\?=&%\+]+/g).forEach(function(t){var e=n.textContent.indexOf(t),a=document.createRange();a.setStart(n,e),a.setEnd(n,e+t.length);var o=document.createElement("a");o.setAttribute("href",0==t.indexOf("http")?t:"h"+t),o.addEventListener("click",function(t){window.open(this.getAttribute("href")),t.preventDefault(),t.stopPropagation()}),a.surroundContents(o),a.detach()})}});
//]]>
</script>
Source by: jsdo.it/kobachi/urltext2anchor
Happy coding \m/
Tidak ada komentar:
Posting Komentar