URL Linkify

Replace URLs in text with clickable links

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

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

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         URL Linkify
// @namespace    http://tampermonkey/url-linkify
// @version      1.1
// @description  Replace URLs in text with clickable links
// @author       Hoopengo
// @match        https://www.google.com/sorry/index*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// @license      Apache 2.0
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const urlRegex = /URL:\s*(\S+)/g; // regex to match "URL: ..." strings
    const textNodes = document.createTreeWalker(document.body, NodeFilter.SHOW_TEXT);

    while (textNodes.nextNode()) {
        const textNode = textNodes.currentNode;

        if (textNode.nodeType === Node.TEXT_NODE && textNode.textContent.match(urlRegex)) {
            const urlMatches = textNode.textContent.match(urlRegex);

            for (let i = 0; i < urlMatches.length; i++) {
                const url = urlMatches[i].replace('URL:', '').trim();
                const link = document.createElement('a');
                link.href = url;
                link.textContent = url;

                // replace the URL text with the link element
                const replacementNode = textNode.splitText(textNode.textContent.indexOf(urlMatches[i]));
                replacementNode.replaceWith(link);
            }
        }
    }
})();