Redirect Removed Steam ID to steamdb

Redirects links to removed AppID's on steampowered.com to steamdb.info

当前为 2018-02-27 提交的版本,查看 最新版本

// ==UserScript==
// @name        Redirect Removed Steam ID to steamdb
// @namespace   https://greasyfork.org/en/users/2205-ryzhehvost
// @description Redirects links to removed AppID's on steampowered.com to steamdb.info
// @description:en Redirects links to removed AppID's on steampowered.com to steamdb.info
// @locale      en-US
// @include     *
// @version     1.2
// @grant       none
// ==/UserScript==
+function () {
    var links = document.getElementsByTagName('a');
    for (var i=links.length-1; i>=0; i--) {
      if (links[i].hasAttribute("href")) {
        if (links[i].getAttribute("href").includes("steampowered")) {
	  links[i].setAttribute("href",links[i].getAttribute("href").replace(/(http.{0,1}:\/\/store\.steampowered\.com\/)(.*)\/(\d+)(.*)/,"$1$2\/$3$4#$2$3"));
	}
      }
    }
  var res;
  if (res=window.location.href.match(/http.{0,1}:\/\/store\.steampowered\.com\/#(\D+)(\d+)/)) {
    window.location = "https:\/\/steamdb.info\/"+res[1]+"\/"+res[2];
  } else if (res=window.location.href.match(/(http.{0,1}:\/\/store\.steampowered\.com\/.+)#(\D+)(\d+)/)){
    window.history.replaceState(null, null, res[1]);
  }
}();