Steam Linkfilter Remover

Removes Steams linkfilter url from url on steamcommunity pages, and replaces them with the correct target url. Script writen by https://github.com/corylulu

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Steam Linkfilter Remover
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Removes Steams linkfilter url from url on steamcommunity pages, and replaces them with the correct target url. Script writen by https://github.com/corylulu
// @author       Ryonez (script by corylulu)
// @match        https://steamcommunity.com/*
// @grant        none
// @run-at       document-idle
// ==/UserScript==

(function() {
    'use strict';

    function processLink(el) {
        var href = el.href;
        if(href) {
            var match = href.match(/https:\/\/steamcommunity.com\/linkfilter\/\?url\=(.*)/);
            if(match) {
                el.href = decodeURIComponent(match[1]);
            }
        }
    }
    // Wait for page to load a bit more, just in case
    setTimeout(function() {
        Array.prototype.forEach.call(document.querySelectorAll('a'), function(el, i) {
            processLink(el);
        });

        // Observer to watch for new links on the page.
        var observer = new MutationObserver(function(mutations) {
            mutations.forEach(function(mutation) {
                if (!mutation.addedNodes) return;
                // For each added node that isn't just plain text, add the same link listener.
                for (var i = 0; i < mutation.addedNodes.length; i++) {
                    var node = mutation.addedNodes[i];
                    if (node.nodeName !== "#text") {
                        Array.prototype.forEach.call(node.querySelectorAll('a'), function(el, i) {
                            processLink(el);
                        });
                    }
                }
            })
        })

        // WARNING: You'll want to tailor this for the site because if it
        //          does a lot of dynamic loading, it can bog things down.
        //          My script monitors for "div.content" to work on reddit,
        //          because that's as specific as I need to be, but using it
        //          on "body" will bog things down when new things load in
        observer.observe(document.querySelector("body"), {
            childList: true
            , subtree: true
            , attributes: false
            , characterData: false
        });
    }, 2000);
})();