Sonkwo_Steam_Search

快捷搜索steam商店

安装此脚本?
作者推荐脚本

您可能也喜欢GMG小绿人Steam快捷搜索

安装此脚本
  1. // ==UserScript==
  2. // @name:zh-CN 杉果Steam快捷搜索
  3. // @name Sonkwo_Steam_Search
  4. // @namespace https://blog.chrxw.com/
  5. // @supportURL https://blog.chrxw.com/scripts.html
  6. // @contributionURL https://afdian.com/@chr233
  7. // @icon https://blog.chrxw.com/favicon.ico
  8. // @version 2.5
  9. // @description 快捷搜索steam商店
  10. // @description:zh-CN 快捷搜索steam商店
  11. // @author Chr_
  12. // @license AGPL-3.0
  13. // @connect steampowered.com
  14. // @match https://www.sonkwo.com/sku/*
  15. // @match https://www.sonkwo.hk/sku/*
  16. // @match https://www.sonkwo.cn/sku/*
  17. // @require https://gf.qytechs.cn/scripts/431430-search-steam-store/code/Search_Steam_Store.js
  18. // @grant GM_xmlhttpRequest
  19. // @grant GM_addStyle
  20. // @grant GM_registerMenuCommand
  21. // ==/UserScript==
  22.  
  23. (() => {
  24. "use strict";
  25. const auto = window.localStorage["ss_auto"] ?? "关";
  26.  
  27. let GdivResult = null; //控件数组
  28.  
  29. const t =setTimeout(() => {
  30. const container = document.querySelector("div.main-content");
  31. if (container !== null) {
  32. const ele =
  33. document.querySelector("div.sku-en-name") ||
  34. document.querySelector("div.sku-cn-name");
  35. if (ele && !ele.querySelector("button.btnSearch")) {
  36. console.log(ele);
  37. init(ele);
  38.  
  39. }}
  40. }, 3000);
  41.  
  42. // container.addEventListener("DOMNodeInserted", ({ relatedNode }) => {
  43. // const ele = document.querySelector("h5.typical-name-2") || document.querySelector("h3.typical-name-1");
  44. // if (ele.querySelector("button.btnSearch") === null) {
  45. // init(ele);
  46. // }
  47. // });
  48.  
  49. //显示搜索按钮
  50. function init(ele) {
  51. const keyword = ele.textContent.replace(/[-+=:;:;""‘’“”]/g, " ");
  52. const btnSearch = document.createElement("button");
  53. btnSearch.className = "btnSearch";
  54. btnSearch.textContent = "🔎";
  55. btnSearch.addEventListener("mouseover", () => {
  56. btnSearch.textContent = "🔎 搜索Steam";
  57. });
  58. btnSearch.addEventListener("mouseout", () => {
  59. btnSearch.textContent = "🔎";
  60. });
  61. btnSearch.addEventListener("click", () => {
  62. showResult(keyword);
  63. });
  64.  
  65. ele.appendChild(btnSearch);
  66. const divResult = document.createElement("div");
  67. divResult.className = "divResult";
  68. ele.appendChild(divResult);
  69.  
  70. GdivResult = divResult;
  71.  
  72. if (auto === "开") {
  73. btnSearch.click();
  74. }
  75. }
  76.  
  77. //显示搜索结果
  78. function showResult(keyword) {
  79. searchStore(keyword, "CN")
  80. .then((result) => {
  81. GdivResult.innerHTML = "";
  82. if (result.length === 0) {
  83. const btnRst = document.createElement("button");
  84. btnRst.textContent = "【快速搜索无结果,点击前往steam搜索页】";
  85. btnRst.addEventListener("click", () => {
  86. window.open(
  87. `https://store.steampowered.com/search/?term=${keyword}`
  88. );
  89. });
  90. GdivResult.appendChild(btnRst);
  91. return;
  92. }
  93. for (const {
  94. appID,
  95. isBundle,
  96. appName,
  97. appPrice,
  98. appUrl,
  99. appImg,
  100. } of result) {
  101. const btnRst = document.createElement("button");
  102. btnRst.title = `${isBundle ? "bundle" : "app"}/${appID}`;
  103. btnRst.addEventListener("click", () => {
  104. window.open(appUrl);
  105. });
  106.  
  107. const btnName = document.createElement("p");
  108. btnName.textContent = `${appName}【${appPrice}】`;
  109. btnRst.appendChild(btnName);
  110. btnRst.appendChild(document.createElement("br"));
  111.  
  112. const btnImg = new Image();
  113. btnImg.src = appImg;
  114.  
  115. btnRst.appendChild(btnImg);
  116. GdivResult.appendChild(btnRst);
  117. }
  118. })
  119. .catch((reason) => {
  120. alert(reason);
  121. });
  122. }
  123.  
  124. GM_registerMenuCommand(`自动搜索:【${auto}】`, () => {
  125. window.localStorage["ss_auto"] = auto === "开" ? "关" : "开";
  126. });
  127. })();
  128.  
  129. //CSS表
  130. GM_addStyle(`
  131. .divResult {
  132. top: -180px;
  133. position: relative;
  134. width: 100%;
  135. overflow-y: hidden;
  136. white-space: nowrap;
  137. }
  138. .divResult > button {
  139. cursor: pointer;
  140. }
  141. .divResult > button:not(:last-child) {
  142. margin-right: 5px;
  143. }
  144. .divResult > button > p {
  145. display: inline;
  146. margin-left: 6px;
  147. }
  148. .divResult > button > img {
  149. zoom: 1.5;
  150. margin-top: 2px;
  151. }
  152. .btnSearch {
  153. padding: 0 5px;
  154. margin-left: 5px;
  155. }
  156.  
  157. `);

QingJ © 2025

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