Uncensored bitcoin url link fixer

make link-like things actually links.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

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

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

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

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Uncensored bitcoin url link fixer
// @namespace    http://tampermonkey.net/
// @version      0.4
// @description  make link-like things actually links.
// @author       It's not lupus. Go away.
// @match        https://www.reddit.com/r/noncensored_bitcoin/*
// @grant        none
// @require      https://cdnjs.cloudflare.com/ajax/libs/findAndReplaceDOMText/0.4.5/findAndReplaceDOMText.min.js
// ==/UserScript==

(function() {
    'use strict';

    var subs = [
        "bitcoin", "btc", "cryptocurrency", // currently active on subreddit
        "bitcoinmarkets", "buttcoin", "ethereum", // not active, but it ain't hurting nobody
        "ethtrader", "bitcoin_uncensored", "bitcoinall",
        "bitcoin_unlimited", "bitcoinbeginners", "bitcoincash",
        "coinbase", "bitcoinmining", "jobs4bitcoin", "openbazaar",
        "bitmarket", "blockstreams", "bitcoinxt", "mtgoxinsolvency",
        "bitcoinserious", "bitcoinnews", "kraken", "redditnotes" ]; // digging deep

    var findRegexp = new RegExp("(?:(?:[a-z]+\.)?reddit\.com)?\\/r\\/ ("+subs.join("|")+")\\S+", "gi");
    var replaceRegexp = new RegExp("r\\/ ("+subs.join("|")+")", "i");

    var fixLinks = _.debounce(function() {
        // regexps are fuzzy. this will probably work, until it doesn't. adjust as needed.
        // this is hardcoded to only work with "/r/ Bitcoin" links. revisit if it needs to match more.
        findAndReplaceDOMText(document.body, {
            find: findRegexp,
            replace: function(portion, matches) {
                var link = matches[0].replace(/^(?:[a-z]+\.)?reddit\.com/i,'').replace(replaceRegexp, 'r\/$1');
                return $("<A>").attr("href", link).text(link)[0];
            }
        });
        // let's make reddit usernames into links too.
        findAndReplaceDOMText(document.body, {
            find: /((?:post|comment) by )(\S+)/gi,
            replace: function (portion, matches) {
                if (portion.text != matches[0]) { // only replace full matches, or we'll end up replacing ourselves.
                    return portion.node.cloneNode();
                }
                var before = matches[1];
                var username = matches[2];
                return $("<span>").text(before).append($("<A>").attr("href", "/u/"+username).text(username))[0];
            }
        });
    }, 250);

    (new MutationObserver(fixLinks)).observe(document.body, {
        childList: true,
        subTree: true
    });
    fixLinks();
})();