Reddit Flair Linkifier

Turns the text in various subreddits' flair into links

目前为 2018-04-28 提交的版本。查看 最新版本

// ==UserScript==
// @name         Reddit Flair Linkifier
// @namespace    https://gf.qytechs.cn/users/649
// @version      2.0.1
// @description  Turns the text in various subreddits' flair into links
// @author       Adrien Pyke
// @match        *://*.reddit.com/*
// @require      https://cdn.rawgit.com/fuzetsu/userscripts/477063e939b9658b64d2f91878da20a7f831d98b/wait-for-elements/wait-for-elements.js
// @grant        none
// ==/UserScript==

(() => {
	'use strict';

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

			// card template
			'.Post > div:nth-of-type(2) > div:nth-of-type(1) > div > div:nth-of-type(1) > div:nth-of-type(2) > span',
			// classic template
			'.Post > div:nth-of-type(2) > div > div:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(2) > span',
			// compact template
			'.Post > div > div:nth-of-type(2) > div > div:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(2) > span',

			// comments
			'.Comment > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(2) > span',

			// moderators
			'.cIMsMe > div > span',

			// user flair preview
			'.QAshv > div > span',

			// flair edit
			'.fhMwuu > div > span'
		].join(','),
		onmatch(flair) {
			flair.innerHTML = flair.textContent.split(' ').map(segment => {
				if (segment.match(/^https?:\/\//)) {
					return `<a href="${segment}" target="_blank" rel="noopener noreferrer">${segment}</a>`;
				} else {
					return segment;
				}
			}).join(' ');
		}
	});
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址