Steam Store - Removed App/Sub Redirect To SteamDB

If the Steam Store app/sub doesn't exist, is removed or is region-locked, redirect to steamdb.info instead of store.steampowered.com.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Steam Store - Removed App/Sub Redirect To SteamDB
// @icon         http://store.steampowered.com/favicon.ico
// @namespace    Royalgamer06
// @version      1.5
// @description  If the Steam Store app/sub doesn't exist, is removed or is region-locked, redirect to steamdb.info instead of store.steampowered.com.
// @author       Royalgamer06 <https://royalgamer06.ga>
// @include      *
// @exclude      file://*
// @connect      store.steampowered.com
// @grant        GM_xmlhttpRequest
// @grant        GM_openInTab
// @grant        unsafeWindow
// @require      http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.js
// ==/UserScript==

// ==Code==
this.$ = this.jQuery = jQuery.noConflict(true);
var CtrlIsPressed = false;
$(document).ready(function() {
    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");
    }
}).on("keydown", function(event) {
    if (event.which == "17") CtrlIsPressed = true;
}).on("keyup", function() {
    CtrlIsPressed = false;
}).on("mousedown", "a[href*='://store.steampowered.com/app/'], a[href*='://store.steampowered.com/sub/']", function(event) {
    event.preventDefault();
    event.returnValue = false;
    event.stopPropagation();
    var href = event.currentTarget.href;
    var target = event.currentTarget.target ? event.currentTarget.target : "_self";
    var w;
    var opened = false;
    switch (event.which) {
        case 1:
            if (CtrlIsPressed) {
                w = unsafeWindow.open(href, "_blank");
                unsafeWindow.focus();
            } else {
                w = unsafeWindow.open(href, target);
            }
            opened = true;
            break;
        case 2:
            w = unsafeWindow.open(href, "_blank");
            unsafeWindow.focus();
            opened = true;
            break;
        default:
            break;
    }
    if (opened) {
        GM_xmlhttpRequest({
            method: "HEAD",
            url: href,
            onload: function(response) {
                if (/^https?:\/\/store\.steampowered.com\/?$/.test(response.finalUrl)) {
                    w.location.href = href.replace("store.steampowered.com", "steamdb.info");
                }
            }
        });
    }
    return false;
});
// ==/Code==