Wishlist profile linkifier and contest search fixer

try to take over the world!

  1. // ==UserScript==
  2. // @name Wishlist profile linkifier and contest search fixer
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author noeatnosleep
  7. // @match https://www.reddit.com/r/Wishlist/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var flairs=document.getElementsByClassName('flair');
  15. for(var i=0;i<flairs.length;i++){flairs[i].innerHTML='<a href=\''+flairs[i].title+'\'>Profile</a>'}})();
  16.  
  17.  
  18.  
  19. var url1,url2;
  20. url1 = ['www.reddit.com/r/Wishlist/search?q=flair:%27contest%27+OR+flair:%27closed%27&restrict_sr=on&sort=new&feature=legacy_search'];
  21. url2 = ['www.reddit.com/r/Wishlist/search?q=flair:%27contest%27&restrict_sr=on&sort=new&feature=legacy_search' ];
  22. var a, links;
  23. var tmp="a";
  24. var p,q;
  25. links = document.getElementsByTagName('a');
  26. for (var i = 0; i < links.length; i++) {
  27. a = links[i];
  28. for(var j=0;j<url1.length; j++)
  29. {
  30. tmp = a.href+"" ;
  31. if(tmp.indexOf(url1[j]) != -1)
  32. {
  33. p=tmp.indexOf(url1[j]) ;
  34. q="http://";
  35. q = q + url2[j] + tmp.substring(p+url1[j].length,tmp.length);
  36. a.href=q ;
  37. }
  38. }
  39. }
  40.  
  41.  
  42.  
  43.  
  44. document.addEventListener("DOMContentLoaded", replaceLinks, false );
  45.  
  46. if( document.readyState === "complete" ) {
  47. replaceLinks();
  48. }
  49.  
  50. function replaceLinks() {
  51. Array.forEach( document.links, function(a) {
  52. a.href = a.href.replace( "'contest'+OR+flair:'closed'&amp", "'contest'&amp");
  53. });
  54. }