// ==UserScript==
// @name 饰品比例计算脚本
// @namespace jkkowo
// @version 1.91
// @description 买买买(基于作者out脚本,新增悠悠有品的支持)
// @author jkkowo
// @icon https://store.steampowered.com/favicon.ico
// @match *://www.c5game.com/*
// @match *://buff.163.com/*
// @match *://www.igxe.cn/product/*
// @match *://www.v5fox.com/*
// @match *://www.youpin898.com/*
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @grant GM_openInTab
// @grant GM_notification
// @grant GM_getValue
// @grant GM_setValue
// @require https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js
// @connect steamcommunity.com
// @supportURL https://steamcn.com/t331397-1-1
// @license MIT
// ==/UserScript==
const $ = window.jQuery;
var site;
var low;
var high;
(function() {
'use strict';
// Your code here...
$(document).ready(function(){
start(query);
});
})();
function start(){
var name,appid;
if($(".steamUrl").length!== 0){
site = "c5";
query($(".steamUrl a").attr("href"));
}else if($('div.detail-summ > a').length !== 0){
site = "buff";
query($('div.detail-summ > a').attr("href"));
}else if($('div.productInfo').length !== 0){
name = $('.productInfo .name').text();
appid = window.location.href.match(/product\/(\d+)/)[1];
site = "ig";
getItemUrl(appid,name);
}else if($('div.goods-details-r').length !==0){
site="v5";
name = $('.goods-details-r .l:first em').text();
switch($('.crumbs a:last').attr('href')){
case "/dota2":
appid=570;
break;
case "/h1z1/kotk":
appid=433850;
break;
case "/csgo":
appid=730;
break
}
if(appid && name){
getItemUrl(appid,name);
}
}else if($('div.grey.f14.mt20').length !== 0){
site = "yyyp";
setTimeout(function(){
query($('div.grey.f14.mt20 > a').attr("href"));
},2000)
}
}
function getItemUrl(appid,name){
GM_xmlhttpRequest({
method: "GET",
responseType: "json",
url: "https://steamcommunity.com/market/search/render/?count=1&q=&appid=" + appid + "&norender=1&query=" + name,
timeout:5000,
onload: function(res){
if(res&&res.response){
var response = res.response;
if(response.success && response.results.length > 0){
query("https://steamcommunity.com/market/listings/" + appid + "/" + response.results[0].hash_name);
}
}
}
});
}
function query(itemUrl){
GM_xmlhttpRequest({
method: "GET",
url: itemUrl,
timeout:5000,
onload: function(res){
if(res.status == "200" &&res.responseText!=="null"){
try{
var g_sessionID = res.responseText.match(/g_sessionID = "([^"]+)"/)[1];
var g_walletCurrency = parseInt(res.responseText.match(/"wallet_currency":(\d+)/)[1]);
var g_strLanguage = res.responseText.match(/g_strLanguage = "([^"]+)"/)[1];
var g_strCountryCode = res.responseText.match(/g_strCountryCode = "([^"]+)"/)[1];
}
catch(err){
steamlogin();
return;
}
try{
var nameid = res.responseText.match(/Market_LoadOrderSpread\( (\d+)/)[1];
}
catch(err){
if(res.responseText.indexOf('market_listing_nav_container') != -1){
steamxj();
return;
}
}
GM_xmlhttpRequest({
timeout:5000,
method: "GET",
url: "https://steamcommunity.com/market/itemordershistogram?country=" + g_strCountryCode + "&language=" + g_strLanguage + "¤cy=" + g_walletCurrency + "&item_nameid=" + nameid,
responseType: "json",
onload: function(data){
var obj = data.response;
if(obj){
if(!obj.lowest_sell_order&&!obj.highest_buy_order){
return;
}
GM_addStyle(`.price > div{ margin-top:4px;font-size:16px; }
.ls, .hb {color:#e46409; }
.lsnf, .hbnf {color:#7ccc35; }
.lsr, .hbr {color:#1ee44a; }
.price > div > span{ text-align:center;display:-moz-inline-box; display:inline-block; width:90px;}
.title { font-size:14px; }
.title > strong:nth-child(1) { margin-left:80px; }
.title > strong:nth-child(2) { margin-left:60px; }
.afkout { float:left;width:280px; }
.afkout strong { color:#afb0b2;font-size: 15px}
`);
var $pinfo = $(`<div class="afkout">
<div class="title">
<strong>出售</strong><strong>求购</strong>
</div>
<div class="price">
<div><strong>价格:</strong><span class="ls"></span><span class="hb"></span></div>
<div><strong>税后:</strong><span class="lsnf"></span><span class="hbnf"></span></div>
<div><strong>比例:</strong><span class="lsr"></span><span class="hbr"></span></div>
</div></div>
`);
if(site=="c5"){
GM_addStyle(` .hero .ft-orange{ display:none }
.hero { position:unset !important; margin:0px }
.name > span:first-child { width:fit-content !important; display: inline-block !important;}
.afkout { margin-top:5px; }
`);
$(".hero").before($pinfo);
}else if(site=="buff"){
GM_addStyle(` .detail-cont > div.blank20 { height:5px;}
.detail-summ span { display:none; margin-right:0px; }
..detail-summ a { float:right }
`);
$("div.detail-summ").prepend($pinfo);
$(".buying, .selling, .history").click(calcratio);
}else if(site=="ig"){
GM_addStyle(` .proposedPrice, .averagePrice { display:none }
.bnts { float:left;margin-top:0px }
.steamUrl a { color:#0b84d3; font-size:16px }
.afkout, .steamUrl, .rarity { margin-top:15px; }
`);
$("div.rarity:last").after($pinfo);
$('.productInfo .name').after($('<div class="steamUrl"><a target="_blank">steam市场链接</a></div>'));
$(".steamUrl a").attr("href",itemUrl);
}else if(site=="v5"){
GM_addStyle(` .goods-details-r h4, .goods-details-r h5 { display:none }
.steamUrl a { color:#0b84d3; font-size:16px ;float:right }
`);
$('.goods-details-r .clearfix').after($('<div class="steamUrl"><a target="_blank">steam市场链接</a></div>')).after($pinfo);
$(".steamUrl a").attr("href",itemUrl);
}else if(site=="yyyp"){
GM_addStyle(`.grey.f14.mt20 > span { display:none;}`);
$("div.grey.f14.mt20").prepend($pinfo);
}
if(obj.lowest_sell_order){
var lowest_sell_order = parseInt(obj.lowest_sell_order);
$("span.ls").text(obj.price_prefix + " " + lowest_sell_order/100);
var lsnofee = calcfee(lowest_sell_order);
$("span.lsnf").text(obj.price_prefix + " " + lsnofee/100);
}
if(obj.highest_buy_order){
var highest_buy_order = parseInt(obj.highest_buy_order);
$("span.hb").text(obj.price_prefix + " " + highest_buy_order/100);
var hbnofee = calcfee(highest_buy_order);
$("span.hbnf").text(obj.price_prefix + " " + hbnofee/100);
}
if(GM_getValue("version","0") != GM_info.script.version) {
GM_setValue("version",GM_info.script.version);
var details = {text: "如果有用请帮忙加点体力(点这里)\r\n提交BUG请附上console输出",
title: "C5比例脚本",
image: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKgAAACoCAYAAAB0S6W0AAAPd0lEQVR4nO2d2XNc1RHGe+5skmXtkiWMdzbbmOAASRVJKsV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lyh5m88ztxq0quw8Oq+16gTdxJSKOfaroxOhxdAPd0O7tVqbngClY1zR2UrTSLqS+q1cRBSLcu+6VA9wBWFdEpFopU0N670OiDh1DXGr3/8FXTJNdMY0gamh2xi7w1mXdBZTehQH8BbGm4QAzrnam6O51C6R9Oq5AN2IrTM6QC02Fm9KH8y/GiSyFhi+82FOgBwPb/qvpksCp/nK27LlWcVKEZDoUqvQ4E+d5swb3Hw0bum6JADwDSLUFjG0TaBR0AGCP+68kkqFpYr8mNjcjlVHuxmBpzpUY1Steg3cwsVAr0Gck+Sv5jSEVGjmr0f/owGv+yzmeFRcUsANcA1yNixXsazoupGagUqAdQ0TMziBW4iLc5phEL2/9KD/S2uxoG/QPFNpYuk6BAPYOt/7Qby5h1AdT7t3fkk+VQlj0U77YTuC0YHzmWt3V/VP/eEdgBEBVj0t1oG6fc+QLVSBPqqmCwhiEDSoG2E2ybuOAWU0OMBMVPZEwfIlR7WXuZFGgbSVpTAidS3BVqFVjMiWLQ9aT8Xtj91FIC/DnMocLpjFWSGoTA5Gv09oqsbQ2WwLRl5Evz9r5/972h5gBB3aBHP8TXb/LykeHFYHOw5FxbArnS10aSCnRr4LDh4mTe1Rz4onmg4QMvryqs1+X+dk3+eWfHPYW2EyqdB1YAM0LXDVZC4YAWuVq0vvhI1eK9Iv+75um9ehFoXEsuE7hSityT0ysnJ50i0/hMLDbqoSLr+/Wk9SX2UE6A7x/53y1P7TPeZtSjVcJXsz7pHGgYXDH8vRl02wl5DAVKTEOBEtNQoMQ0FCgxDQVKTEOBEtNQoMQ0FCgxDQVKTEOBEtNQoMQ0FCgxTYCZQjXWxxGDYOaVK/J3ZpTV8MQQmcafObSbzgxmJaIVJYbANFL0cP0fzsxALxYlHgkAAAAASUVORK5CYII=",
highlight: true,
timeout: 10000,
}
GM_notification(details,function(){ GM_openInTab("https://steamcn.com/t331397-1-1", { active: true }); });
}
low = lsnofee;
high = hbnofee;
calcratio();
}else{
steam302();
}
},
ontimeout:steam302,
onerror: steam302
});
}
},
ontimeout:steam302,
onerror: steam302
});
}
function steam302(){
var $302 = $('<div style="color:#FF0000;margin-top:15px"><span class="glyphicon glyphicon-remove"></span><strong>查询超时,建议使用<a target="_blank" href="https://steamcn.com/t339527-1-1" style="color:#0b84d3">Steam302</a></strong></div>');
if(site=="c5"){
$("div.hero").before($302);
}else if(site=="buff"){
$("div.detail-summ").append($302);
}else if(site=="ig"){
$("div.stock").after($302);
}else if(site=="v5"){
$('.goods-details-r .clearfix').after($302);
}else if(site=="yyyp"){
$("div.grey.f14.mt20").append($302);
}
}
function steamlogin(){
var $login = $('<div style="color:#FF0000;margin-top:15px"><strong>请登录<a target="_blank" href="https://steamcommunity.com/login/" style="color:#0b84d3">steam社区</a></strong></div>');
if(site=="c5"){
$("div.hero").before($login);
}else if(site=="buff"){
$("div.detail-summ").append($login);
}else if(site=="ig"){
$("div.stock").after($login);
}else if(site=="v5"){
$('.goods-details-r .clearfix').after($login);
}else if(site=="yyyp"){
$('div.grey.f14.mt20').append($login);
}
}
function steamxj(){
var $xj = $('<div style="color:#FF0000;margin-top:15px"><strong>物品不在货架上</strong></div>');
if(site=="c5"){
$("div.hero").before($xj);
}else if(site=="buff"){
$("div.detail-summ").append($xj);
}else if(site=="ig"){
$("div.stock").after($xj);
}else if(site=="v5"){
$('.goods-details-r .clearfix').after($xj);
}else if(site=="yyyp"){
$('div.grey.f14.mt20').append($xj);
}
}
function getFloat(str){
try{
var f = parseFloat(str.match(/[\d]{1,}(\.\d+)?/)[0]);
}
catch(err){
return 0;
}
return f;
}
function calcfee(p){
var pnofee = Math.max(Math.floor(p/1.15),1);
var vfee = Math.max(Math.floor(pnofee*0.1),1);
var pfee = Math.max(Math.floor(pnofee*0.05),1);
while((pnofee + vfee + pfee) != p) {
if((pnofee + vfee + pfee) > p) {
pnofee--;
}
if((pnofee + vfee + pfee) < p) {
pnofee++;
}
vfee = Math.max(Math.floor(pnofee*0.1),1);
pfee = Math.max(Math.floor(pnofee*0.05),1);
}
return pnofee;
}
function calcratio(){
var t = setInterval(function(){
var siteprice;
if(site == "c5"){
siteprice = siteprice = getFloat($("tbody .ft-orange:first span").text());
if(!siteprice){
siteprice = getFloat($("tbody .ft-orange:first").text());
}
if(!siteprice){
siteprice = getFloat($(".sale-item-lists span.ft-gold:first").text());
}
} else if(site == "buff"){
siteprice = getFloat($("table a.i_Btn:first").attr('data-price'));
if(!siteprice){
siteprice = getFloat($("table strong.f_Strong:first").text() + $("table strong.f_Strong:first small").text());
}
} else if(site == "ig"){
siteprice = getFloat($("td > span.c-4:first").text());
} else if(site == "v5"){
siteprice = getFloat($("p.list-pri:first").text());
} else if(site=="yyyp"){
siteprice = getFloat($("li:nth-child(1) > div.t-4.price-wrapper > span > span").text());
}
if(siteprice != 0){
if(low) {
$("span.lsr").text((siteprice*100/low).toFixed(2));
}
if(high) {
$("span.hbr").text((siteprice*100/high).toFixed(2));
}
clearInterval(t);
}
},200);
}