Steam Store - Removed App/Sub Redirect To SteamDB

If the Steam Store App or Sub doesn't exist, is removed or is region-locked, redirect to SteamDB.info instead of store.steampowered.com.

La data de 12-12-2016. Vezi ultima versiune.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Steam Store - Removed App/Sub Redirect To SteamDB
// @namespace    Royalgamer06
// @version      0.6
// @description  If the Steam Store App or Sub doesn't exist, is removed or is region-locked, redirect to SteamDB.info instead of store.steampowered.com.
// @author       Royalgamer06
// @include      *
// @exclude      file:*
// @run-at       document-idle
// @connect      store.steampowered.com
// @grant        GM_xmlhttpRequest
// @grant        unsafeWindow
// ==/UserScript==

if (/^https?:\/\/store\.steampowered.com\/(app|sub)\/.+$/.test(location.href)) {
    if (document.getElementById("error_box")) location.href = location.href.replace("store.steampowered.com", "steamdb.info");
}
Array.from(document.querySelectorAll("a[href*='://store.steampowered.com/app/'], a[href*='://store.steampowered.com/sub/']")).forEach(function(linkElem) {
    linkElem.onclick = function() {
        var w = linkElem.target ? unsafeWindow.open(linkElem.href, linkElem.target) : unsafeWindow.open(linkElem.href, "_self");
        GM_xmlhttpRequest({
            method: "HEAD",
            url: linkElem.href,
            onload: function(response) {
                if (/^https?:\/\/store\.steampowered.com\/?$/.test(response.finalUrl)) {
                    w.location.href = linkElem.href.replace("store.steampowered.com", "steamdb.info");
                }
            }
        });
        return false;
    };
});