Skip to content

Instantly share code, notes, and snippets.

@Semidio
Created July 15, 2018 03:04
Show Gist options
  • Save Semidio/aed891889baec03fffc2b70a1264a71d to your computer and use it in GitHub Desktop.
Save Semidio/aed891889baec03fffc2b70a1264a71d to your computer and use it in GitHub Desktop.
Open Steam app in UncensorPat.ch
// ==UserScript==
// @name Open In UncensorPat.ch
// @version 0.0.1
// @description Adds a link to open Steam content in UncensorPat.ch.
// @author Semidio
// @match *://steamcommunity.com/app/*
// @match *://store.steampowered.com/app/*
// @grant none
// ==/UserScript==
function CreateButton(pageId) {
var steamButton = document.createElement("a");
var buttonText = document.createTextNode("UncensorPat.ch");
steamButton.setAttribute("href", "https://www.uncensorpat.ch/game/" + pageId);
steamButton.setAttribute("class", "menuitem");
steamButton.appendChild(buttonText);
var superNav = document.getElementsByClassName("supernav_container")[0];
superNav.appendChild(steamButton);
}
// Thanks David Morales, https://stackoverflow.com/questions/11582512/how-to-get-url-parameters-with-javascript/11582513#11582513
function getURLParameter(name) {
return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.search)||[,""])[1].replace(/\+/g, '%20'))||null;
}
var pageId = "";var currentUrl = window.location.href;var urlParts = currentUrl.split("/");pageId = urlParts[4];CreateButton(pageId);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment