Steam - 添加搜索按鈕

在Steam商店頁面加上搜索按鈕

  1. // ==UserScript==
  2. // @name Steam - 添加搜索按鈕
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.8.2
  5. // @description 在Steam商店頁面加上搜索按鈕
  6. // @author CatTime
  7. // @match http*://store.steampowered.com/app/*
  8. // @icon https://store.steampowered.com/favicon.ico
  9. // @grant none
  10. // @license GNU GPLv3
  11. // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js
  12. // ==/UserScript==
  13.  
  14. (function () {
  15.  
  16. // 1. 定義包含名稱和網址的陣列
  17. const websites = [
  18. { name: "PSearchEngine", url: "https://cse.google.com/cse?cx=20c2a3e5f702049aa&q={1}" },
  19. { name: "RaveGameSearch", url: "https://ravegamesearch.pages.dev/#gsc.tab=0&gsc.q={1}" },
  20. { name: "GOG-Games", url: "https://gog-games.to/search/{1}" },
  21. { name: "ElAmigos", url: "https://www.google.com.tw/search?q={1}+site%3Aelamigos.site" },
  22. { name: "GLOAD", url: "https://gload.to/?s={1}" },
  23. { name: "online-fix", url: "https://online-fix.me/index.php?do=search&subaction=search&story={1}" }
  24.  
  25.  
  26. ];
  27. var appNamearr = [];
  28. const appid = (window.location.pathname.match(/\/app\/(\d+)/) ?? [null, null])[1];
  29. if (appid === null) { return; }
  30. let appName;
  31.  
  32. fetch(`https://store.steampowered.com/api/appdetails?appids=${appid}&l=english`)
  33. .then(response => response.json())
  34. .then(data => {
  35. if (data[appid].success) {
  36. appName = data[appid].data.name;
  37. // 在此可以使用 appName 進行其他程式碼的處理
  38. const args = [appid, appName];
  39. // 2. 在網頁 div.purchase_area_spacer 後面插入多個按鈕
  40. const purchaseAreaSpacer = document.querySelector("div.purchase_area_spacer");
  41. const button = document.createElement("div");
  42. button.classList.add("btn_addtocart");
  43.  
  44. for (let i = 0; i < websites.length; i++) {
  45. const website = websites[i];
  46.  
  47.  
  48. const link = document.createElement("a");
  49. link.classList.add("btn_green_steamui", "btn_medium");
  50. var url = website.url;
  51. url = url.replace(/{(\d)}/g, (match, index) => args[index]);
  52.  
  53. link.setAttribute("href", url);
  54. link.setAttribute("target", "_blank");
  55. const span = document.createElement("span");
  56. span.textContent = website.name;
  57. link.appendChild(span);
  58. button.appendChild(link);
  59.  
  60. }
  61. purchaseAreaSpacer.insertAdjacentElement("afterend", button);
  62. }
  63. })
  64. .catch(error => console.error(error));
  65.  
  66.  
  67.  
  68. })();
  69.  
  70.  

QingJ © 2025

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