Reddit Flair Linkifier

Turns the text in various subreddits' flair into links

当前为 2016-09-26 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Reddit Flair Linkifier
  3. // @namespace https://greasyfork.org/users/649
  4. // @version 1.1.4
  5. // @description Turns the text in various subreddits' flair into links
  6. // @author Adrien Pyke
  7. // @match *://*.reddit.com/*
  8. // @require https://greasyfork.org/scripts/5679-wait-for-elements/code/Wait%20For%20Elements.js?version=122976
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. waitForElems('span.flair', function(flair) {
  16. flair.innerHTML = flair.textContent.split(' ').map(function(segment) {
  17. if (segment.match(/^https?:\/\//)) {
  18. return '<a href="' + segment + '" target="_blank" rel="noopener noreferrer">' + segment + '</a>';
  19. } else {
  20. return segment;
  21. }
  22. }).join(' ');
  23. });
  24. })();