Greasy Fork

Greasy Fork is available in English.

soldout2查询物品均价

try to take over the world!

当前为 2019-07-08 提交的版本,查看 最新版本

// ==UserScript==
// @name         soldout2查询物品均价
// @namespace    http://tampermonkey.net/
// @version      0.5
// @description  try to take over the world!
// @author       You
// @match        https://so2.mutoys.com/
// @require      https://code.jquery.com/jquery-2.2.4.js

// @grant        none

// ==/UserScript==


(function() {
    'use strict';
    var ref = "";
    var check_res;
    var datetime=getNowFormatDate();

    function showprice(){
        var allitem2=document.querySelectorAll('.icon-item2x');
        if(check_res==null){
            getreportdata();
        }else{
            for (var i=0;i<allitem2.length;i++)
            {
                var classlist=allitem2[i].className.trim().split(" ")[2];
                var itemid=classlist.trim().split("-")[2];


                if(document.querySelectorAll("."+classlist)[0].classList.length<4||check_res==null){
                    var dealdata;
                    $.ajax({
                        type: "GET",
                        dataType:"json",
                        async:false,
                        url: "https://so2.mutoys.com/info/deal/"+itemid+"/0",
                        success: function(data){
                            dealdata=data;
                        },
                        error:function(e){
                        }
                    });
                    var systemunit=0;
                    var systemprice=0;
                    var userunit=0;
                    var userprice=0;
                    var requestunit=0;
                    var requestprice=0;
                    var requestdeal="";
                    if(check_res.system.item[itemid]!=null)
                    {
                        systemunit=check_res.system.item[itemid]["unit"]
                        systemprice=check_res.system.item[itemid]["price"]
                    }
                    if(check_res.user.item[itemid]!=null)
                    {
                        userunit=check_res.user.item[itemid]["unit"]
                        userprice=check_res.user.item[itemid]["price"]
                    }
                    if(check_res.request.item[itemid]!=null)
                    {
                        requestunit=check_res.request.item[itemid]["unit"]
                        requestprice=check_res.request.item[itemid]["price"]
                    }
                    if(dealdata!=null&&dealdata[0].res.requests.length>0){
                       requestdeal="<br />现有收单价格:"+dealdata[0].res.requests[0].price+"<br />";
                    }

                    $("."+classlist).parent().parent().parent().append(
                        "<span style='font-size: 70%;color: #2196f3'>"+
                        "NPC---数量-" +systemunit+",均价-"+systemprice+"<br />"+
                        "玩家---数量-" +userunit+",均价-"+userprice+"<br />"+
                        "订单---数量-"+requestunit+",均价-"+requestprice+
                        requestdeal+"</span>"
                    );
                    document.querySelectorAll("."+classlist)[0].classList.add("flag")
                }
            }
        }

    }
    ref = setInterval(function(){
        showprice();
    },2000);

    function getreportdata(){
        $.ajax({
            type: "GET",
            dataType:"json",
            async:false,
            url: "https://s3-ap-northeast-1.amazonaws.com/so2-api.mutoys.com/json/report/buy"+datetime+".json",
            success: function(data){
                check_res= data;
            },
            error:function(e){
            }
        });
    }

    function getdealdata(itemid){
        $.ajax({
            type: "GET",
            dataType:"json",
            async:false,
            url: "https://so2.mutoys.com/info/deal/"+itemid+"/0",
            success: function(data){
                var result=data;
                return result;
            },
            error:function(e){
            }
        });
    }

    function getNowFormatDate(){
        var day = new Date();
        var Year = 0;
        var Month = 0;
        var Day = 0;
        var CurrentDate = "";
        Year= day.getFullYear();//支持IE和火狐浏览器.
        Month= day.getMonth()+1;
        Day = day.getDate()-1;
        CurrentDate += Year;
        if (Month >= 10 ){
            CurrentDate += Month;
        }
        else{
            CurrentDate += "0" + Month;
        }
        if (Day >= 10 ){
            CurrentDate += Day ;
        }
        else{
            CurrentDate += "0" + Day ;
        }
        return CurrentDate;
    }
})();