Show_English_Name

在商店页显示双语游戏名称,点击名称可以复制。

2021-09-08 या दिनांकाला. सर्वात नवीन आवृत्ती पाहा.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Show_English_Name
// @name:zh-CN   Steam显示英文游戏名
// @namespace    https://blog.chrxw.com
// @version      1.2
// @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
// ==/UserScript==


(() => {
    'use strict';

    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 en_title = data.data.name;

            en_title = en_title.replace(/ on Steam$/, '');

            let t = setInterval(() => {
                let ele = document.getElementById('appHubAppName');
                if (ele != null) {
                    clearInterval(t);
                    let raw_title = ele.textContent
                    if (raw_title.toLowerCase() != en_title.toLowerCase()) {
                        ele.textContent = `${raw_title} (${en_title})`;
                        ele.title = '点击复制';
                    }
                    ele.addEventListener('click', () => {
                        GM_setClipboard(ele.textContent, { type: 'text', mimetype: 'text/plain' });
                    });
                }
            }, 500);
        })
        .catch(err => {
            console.error(err);
        });
})();