Created
April 10, 2015 15:52
-
-
Save ChangedNameTo/16decb2d03cc0ba41f6b to your computer and use it in GitHub Desktop.
/r/League Broswer Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name rleague-browser-extension | |
// @namespace reddit_league | |
// @description Links summoner names, and makes other small improvements to /r/League. | |
// @include http://*.reddit.com/r/league | |
// @include http://*.reddit.com/r/League | |
// @include http://*.reddit.com/r/league/* | |
// @include http://*.reddit.com/r/League/* | |
// @include https://*.reddit.com/r/league | |
// @include https://*.reddit.com/r/League | |
// @include https://*.reddit.com/r/league/* | |
// @include https://*.reddit.com/r/League/* | |
// ==/UserScript== | |
(function(){ | |
"use strict"; | |
var open_in_new_tabs = true; | |
var i; | |
var flairs = document.getElementsByClassName($('.flair').attb('title')); | |
var r, a, profile_url; | |
for (i = flairs.length-1; i >= 0; i--) { | |
if (flairs[i].textContent === "") { continue; } | |
if (flairs[i].className.indexOf("NA") !== -1) { r = "na"; } | |
else if (flairs[i].className.indexOf("EUW") !== -1) { r = "euw"; } | |
else if (flairs[i].className.indexOf("asia") !== -1) { r = "as"; } | |
else if (flairs[i].className.indexOf("asia") !== -1) { r = "as"; } | |
else if (flairs[i].className.indexOf("asia") !== -1) { r = "as"; } | |
else if (flairs[i].className.indexOf("asia") !== -1) { r = "as"; } | |
else if (flairs[i].className.indexOf("asia") !== -1) { r = "as"; } | |
else { continue; } | |
profile_url = flairs[i].textContent.replace("#", "-"); | |
a = document.createElement("a"); | |
a.textContent = flairs[i].textContent; | |
flairs[i].textContent = ""; | |
a.href = "https://" + r + ".battle.net/d3/en/profile/" + profile_url + "/"; | |
if (open_in_new_tabs) { | |
a.target = "_new"; | |
} | |
flairs[i].appendChild(a); | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment