// ==UserScript==
// @name 网易 buff 增强脚本
// @namespace out
// @version 0.12
// @description 比例计算 成交量显示 销售价显示
// @author bluebird
// @match *://buff.163.com/market/goods*
// @grant GM_addStyle
// @grant GM_openInTab
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @require https://cdn.bootcss.com/jquery/2.2.4/jquery.min.js
// @connect steamcommunity.com
// @supportURL https://steamcommunity.com/id/bluebird2333/
// @downloadURL none
// ==/UserScript==
const $ = window.jQuery;
(function() {
'use strict';
// Your code here...
$(document).ready(function(){
run();
});
// Your code here...
})();
var volumeNum = 0
var data
function run(){
let marketUrl = $('div.detail-summ > a').attr("href")
getItemVolume(marketUrl)
}
function calc(data){
console.log(data)
if(data){
GM_addStyle(` .detail-cont > div.blank20 { height:5px;}
.detail-summ span { display:none; margin-right:0px; }
..detail-summ a { float:right }
.pricelist {font-size: 0.75rem; float:left}
.red {color:red}
.warn {font-size: 0.75rem;float:right}
`);
if(!data.lowest_sell_order&&!data.highest_buy_order){
return;
}
let lowest = parseInt(data.lowest_sell_order)/100
let highest = parseInt(data.highest_buy_order)/100
let 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());
}
let lowRatio = (siteprice/lowest).toFixed(2)
let highRatio = (siteprice/highest).toFixed(2)
var info = "
- 24小时出售量 :"+volumeNum.toString()+"
- 最高收购价格"+highest.toString()+" 比例:"+lowRatio.toString()+"
- 最低出售价格"+lowest.toString()+" 比例:"+highRatio.toString()+"
"
let priceRange = (siteprice/20).toFixed(2)
let buyPriceMap = {1:0,2:0}
let stableBuyPrice = 0
let buy_order_graph = data.buy_order_graph
var tmp = 0
for (let i = 0; i < buy_order_graph.length; i++) {
let spread = highest - buy_order_graph[i][0]
let itemNum = buy_order_graph[i][1]
let rangeNum = Math.trunc(spread/priceRange)+1
if(rangeNum>3){
break
}
buyPriceMap[rangeNum] += (itemNum-tmp)
if((itemNum-tmp)>=5 & stableBuyPrice===0){
stableBuyPrice = buy_order_graph[i][0]
}
tmp = itemNum
}
if( stableBuyPrice!=0){
info = info + "- 最高稳定收购价格:"+stableBuyPrice.toString()+"
"
}
let sellPriceMap = {1:0,2:0}
let stableSellPrice = 0
let sell_order_graph = data.sell_order_graph
tmp = 0
for (let i = 0; i < sell_order_graph.length; i++) {
let spread = sell_order_graph[i][0] - lowest
let itemNum = sell_order_graph[i][1]
let rangeNum = Math.trunc(spread/priceRange)+1
if(rangeNum>3){
break
}
sellPriceMap[rangeNum] += (itemNum-tmp)
if((itemNum-tmp)>=5 & stableSellPrice===0){
stableSellPrice = sell_order_graph[i][0]
}
tmp = itemNum
}
if(stableSellPrice !=0){
info = info + "- 最低稳定出售价格:"+stableSellPrice.toString()+"
"
}
info = info+"
"
info = info+" "
if(highRatio>0.8){
info = info + "- 比例过低
"
}
if(volumeNum<100){
info = info + "- 每日销售量过低请谨慎购买
"
}
if(buyPriceMap[1]<5){
info = info + "- 目前最高收购价格区间(5%)仅有"+buyPriceMap[1].toString()+"件请谨慎购买
"
}
if(sellPriceMap[1]<5){
info = info + "- 目前最低出售价格区间(5%)仅有"+sellPriceMap[1].toString()+"件请谨慎购买
"
}
info = info+"
"
$("div.detail-summ").prepend(info)
}
}
function getItemVolume(marketUrl){
let oriLink = marketUrl.split('/');
let appid = oriLink[oriLink.length-2];
oriLink = oriLink[oriLink.length-1];
GM_xmlhttpRequest({
method: "get",
url: `https://steamcommunity.com/market/priceoverview/?appid=${appid}&market_hash_name=${oriLink}`,
responseType: "json",
timeout: 3e4,
onload: function (result) {
result = result.response;
if(result.volume){
volumeNum = parseInt(result.volume.replace(/\, ?/gi, ''))
}else{
volumeNum =0
}
getPriceData(marketUrl)
}
});
}
function getPriceData(marketUrl){
GM_xmlhttpRequest({
method: "GET",
url: marketUrl,
timeout:5000,
onload: function(res){
console.log("req ok ")
if(res.status == "200" &&res.responseText!=="null"){
console.log("req status ok ")
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=CN&language=schinese¤cy=23&item_nameid=" + nameid,
responseType: "json",
onload: function(data){
var obj = data.response;
data = obj
calc(data)
}
}
)
}
}
)
}
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 getFloat(str){
try{
var f = parseFloat(str.match(/[\d]{1,}(\.\d+)?/)[0]);
}
catch(err){
return 0;
}
return f;
}