Greasy Fork is available in English.
try to take over the world!
当前为
// ==UserScript==
// @name Steam市场买卖价格小工具
// @namespace http://pronax.wtf/
// @version 0.3.10
// @description try to take over the world!
// @author Pronax
// @include *://steamcommunity.com/market/*
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
(function() {
'use strict';
GM_addStyle(
".price_tool_input{width:4.5rem;height:1rem}.price_tool_div{position:fixed;border-radius:5px;padding:.05rem .3rem .25rem;right:.6rem;top:35%;background-color:#3d697b99;text-align:center}.price_tool_input_div{margin:.2rem 0}.price_tool_input_btn{display:inline-block;line-height:25px;background-color:#eaeaea33;border:1px transparent;cursor:pointer;padding:0 12px;color:#d2d2d2}.price_tool_disabled{background-color:#0006}.price_tool_input_btn_toggle{display:inline-block;border:1px transparent;padding:0 .2rem;cursor:pointer;color:#d2e885;line-height:24px}.price_tool_checkbox{display:none}"
);
GM_addStyle(
".market_listing_their_price>span.market_table_value,.market_listing_my_price>span.market_table_value,.market_listing_num_listings>span.market_table_value{font-size:100%}"
);
var demo_price_tool =
"<div class='price_tool_div market_listing_filter_contents'><form onsubmit='return false' id='price_tool_form'><div class='price_tool_input_div'><label class='price_tool_input_btn' for='real_price'><b>成本</b></label><input class='price_tool_checkbox' type='checkbox' name='lock' value='1'><input type='number' step='0.01' min='0' class='price_tool_input filter_search_box' name='real_price' id='real_price' placeholder='现实价格'/></div><div class='price_tool_input_div'><label class='price_tool_input_btn price_tool_disabled' for='scale'><b>比例</b></label><input class='price_tool_checkbox' type='checkbox' name='lock' value='2' checked><input type='number' step='0.01' min='0' max='1' checked class='price_tool_input filter_search_box' name='scale' id='scale' placeholder='汇率比例'/></div><div class='price_tool_input_div'><label class='price_tool_input_btn' for='money_receive'><b>收款</b></label><input class='price_tool_checkbox' type='checkbox' name='lock' value='3'><input type='number' step='0.01' min='0' class='price_tool_input filter_search_box' name='money_receive' id='money_receive' placeholder='收到的钱'/></div><div class='price_tool_input_div'><label class='price_tool_input_btn' for='money_pays'><b>付款</b></label><input type='number' step='0.01' min='0' class='price_tool_input filter_search_box' name='money_pays' id='money_pays' placeholder='支付价格'/></div></form><div style='margin-top: 0.3rem;'><span class='pagebtn' style='padding: 0 10px' onclick='document.getElementById(\"searchResults_btn_prev\").click()'><</span><span class='price_tool_input_btn_toggle' data-status='false'><b>切换为买家</b></span><span class='pagebtn' style='padding: 0 10px' onclick='document.getElementById(\"searchResults_btn_next\").click()'>></span></div></div>";
document.getElementById("BG_bottom").insertAdjacentHTML("beforeEnd", demo_price_tool);
var input_btn = document.getElementsByClassName("price_tool_input_btn");
var checkbox = document.getElementsByClassName("price_tool_checkbox");
for (let i = 0; i < input_btn.length - 2; i++) {
input_btn[i].onclick = function () {
let checkArr = [];
for (let j = 0; j < checkbox.length; j++) {
if (checkbox[j].checked) {
checkArr.push(1);
}
}
let checked = checkbox[i].checked;
if (checked) {
input_btn[i].style.backgroundColor = "#eaeaea33"
} else {
if (checkArr.length > 1) {
return;
}
input_btn[i].style.backgroundColor = "#00000099"
}
checkbox[i].checked = !checked;
}
}
var toggle_btn = document.getElementsByClassName("price_tool_input_btn_toggle")[0];
input_btn[3].onclick = function () {
let checkArr = [];
for (let j = 0; j < checkbox.length; j++) {
if (checkbox[j].checked) {
checkArr.push(1);
}
}
let checked = checkbox[2].checked;
if (checked) {
input_btn[3].style.backgroundColor = "#eaeaea33"
} else {
if (checkArr.length > 1) {
return;
}
input_btn[3].style.backgroundColor = "#00000099"
}
checkbox[2].checked = !checked;
if (toggle_btn.dataset.status == "false") {
input_btn[2].style.backgroundColor = input_btn[3].style.backgroundColor;
}
}
input_btn[2].onclick = function () {
input_btn[3].click();
}
var real_price = document.getElementById("real_price");
var scale = document.getElementById("scale");
var saved_scale = GM_getValue("price_tool_scale");
if (saved_scale != null) {
scale.value = saved_scale;
}
var money_receive = document.getElementById("money_receive");
var money_pays = document.getElementById("money_pays");
var toggle_div = document.getElementsByClassName("price_tool_input_div")[2];
var tool_targ = document.getElementsByClassName("price_tool_div")[0];
tool_targ.onselectstart = function () {
return false;
}
toggle_btn.onclick = function () {
if (toggle_btn.dataset.status == "false") {
this.style.color = "#62b5d6";
this.innerHTML = "<b>切换为卖家</b>";
toggle_btn.dataset.status = true;
money_receive.disabled = true;
tool_targ.style.backgroundColor = "#59702b99";
toggle_div.style.opacity = "0.3";
money_receive.value = "";
input_btn[2].style.backgroundColor = "#eaeaea33"
} else {
this.style.color = "#D2E885";
this.innerHTML = "<b>切换为买家</b>";
toggle_btn.dataset.status = false;
money_receive.disabled = false;
tool_targ.style.backgroundColor = "#3d697b99";
toggle_div.style.opacity = "1";
input_btn[2].style.backgroundColor = input_btn[3].style.backgroundColor;
}
}
real_price.onchange = function () {
let checkArr = [];
for (let j = 0; j < checkbox.length; j++) {
checkArr.push(checkbox[j].checked);
}
if (toggle_btn.dataset.status == "false") {
if (checkArr[1]) {
if (checkArr[2]) {
money_receive.value = "";
money_pays.value = "";
scale.value = "";
return;
}
money_receive.value = Math.round(this.value / scale.value * 100) / 100;
money_pays.value = Math.round(money_receive.value * 115) / 100;
} else {
scale.value = Math.round(this.value / money_receive.value * 100) / 100;
}
} else {
if (checkArr[1]) {
if (checkArr[2]) {
scale.value = "";
money_pays.value = "";
return;
}
money_pays.value = Math.round(this.value / scale.value * 100) / 100;
} else {
scale.value = Math.round(this.value / money_pays.value * 100) / 100;
}
}
}
scale.onchange = function () {
GM_setValue("price_tool_scale", this.value);
let checkArr = [];
for (let j = 0; j < checkbox.length; j++) {
checkArr.push(checkbox[j].checked);
}
if (toggle_btn.dataset.status == "false") {
if (checkArr[0]) {
if (checkArr[2]) {
money_receive.value = "";
money_pays.value = "";
real_price.value = "";
return;
}
money_receive.value = Math.round(real_price.value / this.value * 100) / 100;
money_pays.value = Math.round(money_receive.value * 115) / 100;
} else {
real_price.value = Math.round(money_receive.value * this.value * 100) / 100;
if (checkArr[2]) {
return;
}
real_price.value = "";
money_receive.value = "";
money_pays.value = "";
}
} else {
if (checkArr[0]) {
if (checkArr[2]) {
money_pays.value = "";
real_price.value = "";
return;
}
money_pays.value = Math.round(real_price.value / this.value * 100) / 100;
} else {
if (checkArr[2]) {
real_price.value = Math.round(money_pays.value * this.value * 100) / 100;
return;
}
real_price.value = "";
money_pays.value = "";
}
}
}
money_receive.onchange = function () {
let checkArr = [];
for (let j = 0; j < checkbox.length; j++) {
checkArr.push(checkbox[j].checked);
}
if (toggle_btn.dataset.status == "false") {
money_pays.value = Math.round(this.value * 115) / 100;
if (checkArr[1]) {
if (checkArr[0]) {
real_price.value = "";
scale.value = "";
return;
}
real_price.value = Math.round(this.value * scale.value * 100) / 100;
} else {
if (checkArr[0]) {
scale.value = Math.round(real_price.value / this.value * 100) / 100;
return;
}
real_price.value = "";
scale.value = "";
}
}
}
money_pays.onchange = function () {
let checkArr = [];
for (let j = 0; j < checkbox.length; j++) {
checkArr.push(checkbox[j].checked);
}
if (toggle_btn.dataset.status == "false") {
money_receive.value = (Math.round(this.value / 0.0115) + 1) / 100;
if (checkArr[1]) {
if (checkArr[0]) {
real_price.value = "";
scale.value = "";
return;
}
real_price.value = Math.round(money_receive.value * scale.value * 100) / 100;
} else {
if (checkArr[0]) {
scale.value = Math.round(real_price.value / this.value * 100) / 100;
return;
}
real_price.value = "";
scale.value = "";
}
} else {
if (checkArr[1]) {
if (checkArr[0]) {
real_price.value = "";
scale.value = "";
return;
}
real_price.value = Math.round(this.value * scale.value * 100) / 100;
} else {
if (checkArr[0]) {
scale.value = Math.round(real_price.value / this.value * 100) / 100;
return;
}
real_price.value = "";
scale.value = "";
}
}
}
console.log("买卖价格插件加载成功--Pronax");
})();