Steam历史价格查询

跳转到SteamDB

目前为 2023-07-24 提交的版本。查看 最新版本

// ==UserScript==
// @name         Steam历史价格查询
// @description  跳转到SteamDB
// @author       shopkeeperV
// @namespace    https://gf.qytechs.cn/zh-CN/users/150069
// @version      1.0.1
// @match        https://store.steampowered.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    let path = location.pathname;
    let page_type;
    let title_eles;
    if (/app/.test(path)) {
        page_type = "app";
        title_eles = document.getElementsByClassName("apphub_AppName");
        let wrappers = document.getElementsByClassName("game_area_purchase_game_wrapper");
        for (let wrapper of wrappers) {
            let item_type;
            let item_id;
            let form = wrapper.getElementsByTagName("form")[0];
            let inputs = form.getElementsByTagName("input");
            for (let input of inputs) {
                if (/subid|bundleid/.test(input.name)) {
                    if (/subid/.test(input.name)) {
                        item_type = "sub";
                    } else if (/bundleid/.test(input.name)) {
                        item_type = "bundle";

                    }
                    item_id = input.value;
                    break;
                }
            }
            wrapper.getElementsByTagName("h1")[0].appendChild(createASpan(item_type, item_id));
        }
    } else {
        if (/sub/.test(path)) {
            page_type = "sub";
        } else if (/bundle/.test(path)) {
            page_type = "bundle";
        } else return;
        title_eles = document.getElementsByClassName("pageheader");
    }
    let page_id = path.match(/\/([0-9]*?)\//i)[1];
    for (let title_ele of title_eles) {
        title_ele.appendChild(createASpan(page_type, page_id));
    }

    function createASpan(db_type, db_id) {
        let span = document.createElement("span");
        span.setAttribute("class", "history_price");
        span.textContent = "查价";
        span.style.cssText = "display:inline-block;margin-left:10px;color:yellow;cursor:pointer;";
        span.db_type = db_type;
        span.db_id = db_id;
        span.onclick = (e) => {
            let db_url = "https://steamdb.info/" + e.target.db_type + "/%s/";
            window.open(db_url.replace("%s", e.target.db_id));
        };
        return span;
    }
})();

QingJ © 2025

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