Greasy Fork is available in English.

Show_English_Name

在商店页显示双语游戏名称,双击名称可以快捷搜索。

Tính đến 08-09-2021. Xem phiên bản mới nhất.

// ==UserScript==
// @name         Show_English_Name
// @name:zh-CN   Steam显示英文游戏名
// @namespace    https://blog.chrxw.com
// @version      1.4
// @description  在商店页显示双语游戏名称,双击名称可以快捷搜索。
// @description:zh-CN  在商店页显示双语游戏名称,双击名称可以快捷搜索。
// @author       Chr_
// @include      /https://store\.steampowered\.com\/app\/\d+/
// @require      https://greasyfork.org/scripts/431423-async-requests/code/Async_Requests.js
// @connect      store.steampowered.com
// @license      AGPL-3.0
// @icon         https://blog.chrxw.com/favicon.ico
// @grant        GM_setClipboard
// @grant        GM_xmlhttpRequest
// @grant        GM_registerMenuCommand
// ==/UserScript==


(() => {
    'use strict';
    let mode = window.localStorage['sen_mode'] ?? 'c(e)';
    let appid = (window.location.pathname.match(/\/app\/(\d+)/) ?? [null, null])[1];
    if (appid === null) { return; }
    $http.get(`https://store.steampowered.com/api/appdetails?appids=${appid}&l=english`)
        .then(json => {
            let data = json[appid];
            if (data.success !== true) { return; }
            let name_en = data.data.name;
            let t = setInterval(() => {
                let ele_title = document.getElementById('appHubAppName');
                if (ele_title != null) {
                    clearInterval(t);
                    let ele_path = document.querySelector('div.blockbg>a:last-child');
                    let name_cur = ele_title.textContent
                    if (name_cur.toLowerCase() != name_en.toLowerCase()) {
                        let name_new = '';
                        if (mode === 'e(c)') {
                            name_new = `${name_en} (${name_cur})`;
                        } else {
                            name_new = `${name_cur} (${name_en})`;
                        }
                        ele_title.textContent = name_new;
                        if (ele_path !== null) {
                            ele_path.textContent = name_new;
                        }
                    }
                    ele_title.title = '双击快捷搜索';
                    ele_title.addEventListener('dblclick', () => {
                        ShowConfirmDialog(`⚠️询问`, '<h1>搜索关键词</h1>', name_cur, name_en)
                            .done(() => {
                                window.open(`https://store.steampowered.com/search/?term=${name_cur}`);
                            })
                            .fail(() => {
                                window.open(`https://store.steampowered.com/search/?term=${name_en}`);
                            })
                    });
                }
            }, 500);
        })
        .catch(err => {
            console.error(err);
        });
    GM_registerMenuCommand('显示格式:原名 (英文名)', () => { window.localStorage['sen_mode'] = 'c(e)'; })
    GM_registerMenuCommand('显示格式:英文名 (原名)', () => { window.localStorage['sen_mode'] = 'e(c)'; })
})();