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.

Stan na 19-03-2017. Zobacz najnowsza wersja.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Steam Store - Removed App/Sub Redirect To SteamDB
// @namespace    Royalgamer06
// @version      1.4
// @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:*
// @connect      store.steampowered.com
// @grant        GM_xmlhttpRequest
// @grant        unsafeWindow
// @require      http://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.js
// ==/UserScript==

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;
        case 3:
            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;
    /*  var linkElem = this;
    var href = linkElem.href;
    linkElem.style.cursor = "pointer";
    linkElem.onclick = function(ev) {
        ev.preventDefault();
        linkElem.removeAttribute("href");
    };
    linkElem.onmousedown = function(ev) {
        ev.preventDefault();
        linkElem.removeAttribute("href");
    };
    linkElem.onmouseup = function(ev) {
        ev.preventDefault();
        var w;
        var check = true;
        if (ev.button) {
            if (ev.button == 1) {
                w = unsafeWindow.open(href, "_blank");
            } else if (ev.button == 2) {
                check = false;
            }
        } else {
            w = linkElem.target ? unsafeWindow.open(href, linkElem.target) : unsafeWindow.open(href, "_self");
        }
        if (check) {
            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");
                    }
                }
            });
        }
        setTimeout(function(){
            linkElem.setAttribute("href", href);
        }, 10);
    };*/
});