Reddit Flair Linkifier

Turns the text in various subreddits' flair into links

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey 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 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.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

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         Reddit Flair Linkifier
// @namespace    https://greatest.deepsurf.us/users/649
// @version      2.1.7
// @description  Turns the text in various subreddits' flair into links
// @author       Adrien Pyke
// @match        *://*.reddit.com/*
// @require      https://cdn.jsdelivr.net/gh/fuzetsu/userscripts@ec863aa92cea78a20431f92e80ac0e93262136df/wait-for-elements/wait-for-elements.js
// @grant        GM_addStyle
// ==/UserScript==

(() => {
  'use strict';

  GM_addStyle(`
		.flair-link {
			text-decoration: none;
		}
		.flair-link:hover {
			text-decoration: underline;
		}
	`);

  const newLayoutId = '#SHORTCUT_FOCUSABLE_DIV';

  waitForElems({
    sel: [
      // old reddit
      'span.flair',
      'span.Comment__authorFlair',

      // new reddit
      `${newLayoutId} span`
    ].join(','),
    onmatch(flair) {
      if (
        flair.childNodes.length !== 1 ||
        flair.childNodes[0].nodeType !== Node.TEXT_NODE ||
        flair.closest('.DraftEditor-root')
      )
        return;
      const newhtml = flair.textContent
        .split(' ')
        .map(segment =>
          segment.match(/^https?:\/\//u)
            ? `<a href="${segment}" class="flair-link" target="_blank" rel="noopener noreferrer">${segment}</a>`
            : segment
        )
        .join(' ');
      if (flair.innerHTML !== newhtml) flair.innerHTML = newhtml;
    }
  });
})();