Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// ==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
You can’t perform that action at this time.