reddit clickable linkflair

turns flairs to links that search the sub for threads with the same flair

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         reddit clickable linkflair
// @namespace    https://greasyfork.org/en/users/36620
// @version      0.2
// @description  turns flairs to links that search the sub for threads with the same flair
// @author       scriptfairy
// @match        https://www.reddit.com/r/*
// @grant        none
// ==/UserScript==

(function($) {
    $('<style>').text('.linkflairlabel > a, .linkflairlabel > a:visited {color:inherit;}').appendTo($('head'));

    var flair, flairTitle, searchContent;
    var linkFlairs = $('.linkflairlabel');
    var sub = location.href;
    sub = sub.slice(0, sub.indexOf("/", sub.indexOf("/r/")+3));

    for (i = 0; i < linkFlairs.length; i++) {
        flair = linkFlairs[i];
        flairTitle = $(flair).attr('title');
        searchContent = encodeURIComponent("flair_text:'"+flairTitle+"'").replace(/%20/g, "+");
        $(flair).html('<a href="'+sub+'/search?q='+searchContent+'&restrict_sr=on">'+flairTitle+'</a>');
    }

})(window.jQuery);