Skip to content

Instantly share code, notes, and snippets.

@sapphyrus
Created May 12, 2017 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sapphyrus/1e76a7f39df3c507ce1b171a174e536c to your computer and use it in GitHub Desktop.
Save sapphyrus/1e76a7f39df3c507ce1b171a174e536c to your computer and use it in GitHub Desktop.
// ==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