Greasy Fork

Shined up real nice.

Wishlist profile linkifier and contest search fixer

try to take over the world!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// ==UserScript==
// @name         Wishlist profile linkifier and contest search fixer
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       noeatnosleep
// @match        https://www.reddit.com/r/Wishlist/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

var flairs=document.getElementsByClassName('flair');
    for(var i=0;i<flairs.length;i++){flairs[i].innerHTML='<a href=\''+flairs[i].title+'\'>Profile</a>'}})();



var url1,url2;
url1 = ['www.reddit.com/r/Wishlist/search?q=flair:%27contest%27+OR+flair:%27closed%27&restrict_sr=on&sort=new&feature=legacy_search'];
url2 = ['www.reddit.com/r/Wishlist/search?q=flair:%27contest%27&restrict_sr=on&sort=new&feature=legacy_search' ]; 
var a, links;
var tmp="a";
var p,q;
links = document.getElementsByTagName('a');
for (var i = 0; i < links.length; i++) {
    a = links[i];
    for(var j=0;j<url1.length; j++)
    {
    tmp = a.href+"" ;
    if(tmp.indexOf(url1[j]) != -1)
    {
    p=tmp.indexOf(url1[j]) ;
    q="http://";
    q = q + url2[j] + tmp.substring(p+url1[j].length,tmp.length);
    a.href=q ;
    }
    }
    }




document.addEventListener("DOMContentLoaded", replaceLinks, false );

if( document.readyState === "complete" ) {
    replaceLinks();
}

function replaceLinks() {
    Array.forEach( document.links, function(a) {
        a.href = a.href.replace( "'contest'+OR+flair:'closed'&amp", "'contest'&amp");
    });
}