🏠 Home 

GMG_Steam_Search

快捷搜索steam商店


ติดตั้งสคริปต์นี้?
สคริปต์ที่แนะนำของผู้เขียน

คุณอาจชื่นชอบ Sonkwo_Steam_Search


ติดตั้งสคริปต์นี้
// ==UserScript==
// @name:zh-CN      GMG小绿人Steam快捷搜索
// @name            GMG_Steam_Search
// @namespace       https://blog.chrxw.com/
// @supportURL      https://blog.chrxw.com/scripts.html
// @contributionURL https://afdian.net/@chr233
// @icon            https://blog.chrxw.com/favicon.ico
// @version         1.6
// @description     快捷搜索steam商店
// @description:zh-CN  快捷搜索steam商店
// @author          Chr_
// @license         AGPL-3.0
// @connect         steampowered.com
// @match           https://www.greenmangaming.com/*/games/*
// @match           https://www.greenmangaming.com/games/*
// @require         https://greasyfork.org/scripts/431430-search-steam-store/code/Search_Steam_Store.js
// @grant           GM_xmlhttpRequest
// @grant           GM_addStyle
// @grant           GM_registerMenuCommand
// ==/UserScript==
(() => {
"use strict";
const auto = window.localStorage["gs_auto"] ?? "关";
const GdivR###lt = [null, null]; //控件数组
let i = 0;
let t = setInterval(() => {
const title1 = document.querySelector("div[class^=visible]>#pdp-title>h1.notranslate");
const describe1 = document.querySelector("div[class^=visible]>#pdp-title>ul.navigate-options");
const title2 = document.querySelector("div[class*=hidden]>#pdp-title>h1.notranslate");
const describe2 = document.querySelector("div[class*=hidden]>#pdp-title>ul.navigate-options");
if (title1 !== null) {
init(title1, describe1, 0);
}
if (title2 !== null) {
init(title2, describe2, 1);
}
if ((GdivR###lt[0] !== null && GdivR###lt[1] !== null) || i++ >= 10) {
clearInterval(t);
}
}, 500);
//显示搜索按钮
function init(title, describe, which) {
const keyword = title.textContent.replace(/[-+=:;:;""‘’“”]/g, " ");
const btnSearch = document.createElement("button");
btnSearch.className = "btnSearch";
btnSearch.textContent = "🔎";
btnSearch.addEventListener("mouseover", () => { btnSearch.textContent = "🔎 搜索Steam"; });
btnSearch.addEventListener("mouseout", () => { btnSearch.textContent = "🔎"; });
btnSearch.addEventListener("click", () => { showR###lt(keyword); });
(describe ?? title).appendChild(btnSearch);
const divR###lt = document.createElement("div");
divR###lt.className = "divR###lt";
divR###lt.style.display = "none";
title.appendChild(divR###lt);
GdivR###lt[which] = divR###lt;
if (auto === "开" && which == 1) {
btnSearch.click();
}
}
//显示搜索结果
function showR###lt(keyword) {
const [divR###lt1, divR###lt2] = GdivR###lt;
searchStore(keyword, "CN")
.then((r###lt) => {
divR###lt1.innerHTML = "";
divR###lt2.innerHTML = "";
divR###lt1.style.display = "";
divR###lt2.style.display = "";
if (r###lt.length === 0) {
const btnRst = document.createElement("button");
btnRst.textContent = "【快速搜索无结果,点击前往steam搜索页】";
btnRst.addEventListener("click", () => { window.open(`https://store.steampowered.com/search/?term=${keyword}`); });
divR###lt1.appendChild(btnRst);
divR###lt2.appendChild(btnRst);
return;
}
for (const { appID, isBundle, appName, appPrice, appUrl, appImg } of r###lt) {
const btnRst = document.createElement("button");
btnRst.title = `${isBundle ? "bundle" : "app"}/${appID}`;
btnRst.addEventListener("click", () => { window.open(appUrl); });
const btnName = document.createElement("p");
btnName.textContent = `${appName}【${appPrice}】`;
btnRst.appendChild(btnName);
btnRst.appendChild(document.createElement("br"));
const btnImg = new Image();
btnImg.src = appImg;
btnRst.appendChild(btnImg);
divR###lt1.appendChild(btnRst);
divR###lt2.appendChild(btnRst);
}
})
.catch((reason) => {
alert(reason);
});
}
GM_registerMenuCommand(`自动搜索:【${auto}】`, () => {
window.localStorage["gs_auto"] = auto === "开" ? "关" : "开";
});
})();
//CSS表
GM_addStyle(`
.divR###lt {
top: 0;
position: relative;
width: 100%;
overflow-x: scroll;
overflow-y: hidden;
white-space: nowrap;
}
.divR###lt > button {
cursor: pointer;
color: #000;
font-size: 15px;
}
.divR###lt > button:not(:last-child) {
margin-right: 5px;
}
.divR###lt > button > p {
display: inline;
margin-left: 6px;
}
.divR###lt > button > img {
zoom: 1.5;
margin-top: 2px;
}
.btnSearch {
padding: 1px;
color: #000;
font-size: 10px;
}
`);