Created
May 12, 2017 23:10
-
-
Save sapphyrus/1e76a7f39df3c507ce1b171a174e536c to your computer and use it in GitHub Desktop.
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 GameTracker.com direct links | |
// @version 2.1 | |
// @namespace www.gametracker.com | |
// @author sapphyrus | |
// @description Converts Join Buttons in the search results to clickable links to Steam games. | |
// @include http*.gametracker.com/server_info/* | |
// @include http*.gametracker.com/search/* | |
// ==/UserScript== | |
if(document.URL.match(/gametracker\.com\/search\//i)) { //Search page | |
var links = document.querySelectorAll("a[href^='javascript:showPopupExternalLink']"); | |
for(var i = 0, l = links.length; i < l; i++) { | |
var el = links[i]; | |
var link = "steam://connect/" + el.href.split("&ip=")[1].replace("&port=", ":").split("'")[0]; | |
el.href = link; | |
} | |
} else { //Server info page | |
var link = "steam://connect/" + document.URL.match(/\d+\.\d+\.\d+\.\d+:\d+/)[0]; | |
var buttons = document.querySelectorAll("span[onclick^='showPopupExternalLink(']"); | |
for(var i = 0, l = buttons.length; i < l; i++) { | |
var el = buttons[i]; | |
el.onclick = null; | |
el.addEventListener ("click", function(){ | |
window.open(link,"_self"); | |
} , false); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment