您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Display images of selected languages on store search steam page.
当前为
- // ==UserScript==
- // @name Steam | Display game languages
- // @name:uk Steam | Відобразити мови гри
- // @namespace http://tampermonkey.net/
- // @version 2.1.2024
- // @description Display images of selected languages on store search steam page.
- // @description:uk Виводить обрані мови (svg картинка) на сторінці пошуку ігр в steam.
- // @author Black_Yuzia
- // @match https://store.steampowered.com/search*
- // @icon https://store.steampowered.com/favicon.ico
- // @grant GM_addStyle
- // @grant GM_xmlhttpRequest
- // @grant GM.getValue
- // @grant GM.setValue
- // @grant GM.registerMenuCommand
- // @grant GM.notification
- // @run-at document-body
- // @license BY-NC-ND 4.0
- // @license-url https://creativecommons.org/licenses/by-nc-nd/4.0/
- // @compatible firefox
- // @compatible chrome
- // @compatible opera
- // @compatible safari
- // @compatible edge
- // @require https://code.jquery.com/jquery-3.7.1.slim.min.js
- // @connect localhost:1500
- // @connect tm.starserv.net
- // ==/UserScript==
- (() => {
- // src/inject.ts
- var baseURL = "https://tm.starserv.net";
- // src/index.ts
- // @license BY-NC-ND 4.0
- // @license-url https://creativecommons.org/licenses/by-nc-nd/4.0/
- (async function() {
- "use strict";
- GM_addStyle(`
- .mr-2 {
- margin-right: 2px
- }
- `);
- const baseURL2 = baseURL || "http://localhost:1500";
- const notification = await GM.getValue("notification", false);
- const languages = await GM.getValue("languages", ["ukrainian", "russian"]);
- console.log("lang", languages);
- if (!notification) {
- await GM.notification("Please choose languages in menu! Default lang: 'Ukrainian,\u0279ussian'", "Warning");
- }
- await GM.registerMenuCommand("Set Languages", async () => {
- const languages2 = prompt("Set language(s) [example: Ukrainian,English,\u0279ussian]");
- if (languages2) {
- await GM.setValue("notification", true);
- await GM.setValue("languages", languages2.split(",").map((v) => v.trim().toLowerCase()));
- }
- });
- const container = await waitForElement("#search_result_container");
- const observer = new MutationObserver(async (mutations) => {
- const elements = [];
- for (const mutate of mutations) {
- const e = mutate.target;
- if (e.className?.includes("search_result_row") && !e.className?.includes("tm_process")) {
- e.className += " tm_process";
- elements.push(e);
- }
- }
- if (elements.length > 0) {
- const ids = elements.map(parseGameID);
- GM_xmlhttpRequest({
- url: `${baseURL2}/steam/games/lang?id=${ids.join(",")}`,
- method: "GET",
- fetch: true,
- responseType: "json",
- onload(res) {
- if (res.status === 200) {
- const { response } = res;
- for (let i = 0; i < response.length; i++) {
- const items = response[i];
- if (items.length > 0) {
- for (const lang of languages) {
- if (items.includes(lang)) {
- const element = elements[i];
- const img = document.createElement("img");
- img.height = 20;
- img.width = 20;
- img.className = "mr-2";
- img.src = `https://fastdl.starserv.net/languages/${lang}@2x.svg`;
- const platforms = $(element).find(".platform_img").first().parent("div");
- platforms.append(img);
- }
- }
- }
- }
- }
- }
- });
- }
- });
- observer.observe(container, {
- childList: true,
- subtree: true
- });
- })();
- function waitForElement(selector) {
- let i = 0;
- return new Promise((resolve) => {
- if (document.querySelector(selector)) {
- return resolve(document.querySelector(selector));
- }
- const observer = new MutationObserver((mutations) => {
- if (document.querySelector(selector)) {
- observer.disconnect();
- resolve(document.querySelector(selector));
- }
- });
- observer.observe(document.body, {
- childList: true,
- subtree: true
- });
- });
- }
- function parseGameID(e) {
- const link = e.attributes.getNamedItem("href")?.value;
- const [id] = link.match(/\d+/) || [];
- return id;
- }
- })();