Reddit Flair Linkifier

Turns the text in various subreddits' flair into links

当前为 2018-03-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Reddit Flair Linkifier
  3. // @namespace https://greasyfork.org/users/649
  4. // @version 1.1.6
  5. // @description Turns the text in various subreddits' flair into links
  6. // @author Adrien Pyke
  7. // @match *://*.reddit.com/*
  8. // @require https://cdn.rawgit.com/fuzetsu/userscripts/477063e939b9658b64d2f91878da20a7f831d98b/wait-for-elements/wait-for-elements.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (() => {
  13. 'use strict';
  14.  
  15. waitForElems({
  16. sel: 'span.flair',
  17. onmatch(flair) {
  18. flair.innerHTML = flair.textContent.split(' ').map(segment => {
  19. if (segment.match(/^https?:\/\//)) {
  20. return `<a href="${segment}" target="_blank" rel="noopener noreferrer">${segment}</a>`;
  21. } else {
  22. return segment;
  23. }
  24. }).join(' ');
  25. }
  26. });
  27. })();