Linkify

Turn plain-text URLs into hyperlinks

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==

// @name		  Linkify
// @version        0.1
// @namespace	  http://youngpup.net/userscripts

// @description   Turn plain-text URLs into hyperlinks

// @include *

// ==/UserScript==



// based on code by Aaron Boodman

// and included here with his gracious permission



var urlRegex = /\b(https?:\/\/[^\s+\"\<\>]+)/ig;

var snapTextElements = document.evaluate("//text()[not(ancestor::a) " + 

                                         "and not(ancestor::script) and not(ancestor::style) and " + 

                                         "contains(translate(., 'HTTP', 'http'), 'http')]", 

                                         document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);

for (var i = snapTextElements.snapshotLength - 1; i >= 0; i--) {

    var elmText = snapTextElements.snapshotItem(i);

    if (urlRegex.test(elmText.nodeValue)) {

        var elmSpan = document.createElement("span");

        var sURLText = elmText.nodeValue;

        elmText.parentNode.replaceChild(elmSpan, elmText);

        urlRegex.lastIndex = 0;

        for (var match = null, lastLastIndex = 0;

             (match = urlRegex.exec(sURLText)); ) { 

            elmSpan.appendChild(document.createTextNode(

                sURLText.substring(lastLastIndex, match.index))); 

            var elmLink = document.createElement("a"); 

            elmLink.setAttribute("href", match[0]); 

            elmLink.appendChild(document.createTextNode(match[0])); 

            elmSpan.appendChild(elmLink); 

            lastLastIndex = urlRegex.lastIndex;

        }

        elmSpan.appendChild(document.createTextNode(

            sURLText.substring(lastLastIndex)));

        elmSpan.normalize();

    }

}