Greasy Fork is available in English.
跳转到SteamDB
当前为
// ==UserScript==
// @name Steam历史价格查询
// @description 跳转到SteamDB
// @author shopkeeperV
// @namespace http://greasyfork.icu/zh-CN/users/150069
// @version 1.0.0
// @match https://store.steampowered.com/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
let path = location.pathname;
let page_type;
let title_ele;
if (/app/.test(path)) {
page_type = "app";
title_ele = document.getElementById("appHubAppName");
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_ele = document.getElementsByClassName("pageheader")[0];
}
let page_id = path.match(/\/([0-9]*?)\//i)[1];
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;
}
})();