Redirect Removed Steam ID to steamdb

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

  1. // ==UserScript==
  2. // @name Redirect Removed Steam ID to steamdb
  3. // @namespace https://gf.qytechs.cn/en/users/2205
  4. // @description Redirects links to removed AppID's on steampowered.com to steamdb.info
  5. // @description:en Redirects links to removed AppID's on steampowered.com to steamdb.info
  6. // @license Apache-2.0
  7. // @author Rudokhvist
  8. // @locale en-US
  9. // @include *
  10. // @version 1.4
  11. // @grant none
  12. // ==/UserScript==
  13. function addanchors(element) {
  14. try {
  15. var links = element.getElementsByTagName('a');
  16. for (var i=links.length-1; i>=0; i--) {
  17. if (links[i].hasAttribute("href")) {
  18. if (links[i].getAttribute("href").includes("steampowered")) {
  19. if (!links[i].getAttribute("href").includes("#")){
  20. links[i].setAttribute("href",links[i].getAttribute("href").replace(/(http.{0,1}:\/\/store\.steampowered\.com\/)([^\/]*)\/(\d+)(.*)/,"$1$2\/$3$4#$2$3"));
  21. }
  22. }
  23. }
  24. }
  25. return null;
  26. } catch (e) {
  27. console.log("Redirect Removed Steam ID to steamdb error");
  28. return null;
  29. }
  30. }
  31.  
  32. +function () {
  33. var res;
  34. if (res=window.location.href.match(/http.{0,1}:\/\/store\.steampowered\.com\/#(\D+)(\d+)/)) {
  35. window.location = "https:\/\/steamdb.info\/"+res[1]+"\/"+res[2];
  36. } else if (res=window.location.href.match(/(http.{0,1}:\/\/store\.steampowered\.com\/.+)#(\D+)(\d+)/)){
  37. window.history.replaceState(null, null, res[1]);
  38. }
  39. addanchors(document);
  40. var mutationObserver = new MutationObserver(function(mutations) {
  41. mutations.forEach(function(mutation) {
  42. mutation.addedNodes.forEach( function(currentValue, currentIndex, listObj) {
  43. if (currentValue.nodeType == Node.ELEMENT_NODE) {
  44. addanchors(currentValue);
  45. }
  46. });
  47. });
  48. });
  49. mutationObserver.observe(document.documentElement, {
  50. childList: true,
  51. subtree: true
  52. });
  53. }();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址