大力出逗比

网易BUFF脚本
网易BUFF爬取皮肤脚本
扫描右侧二维码阅读全文
10
2018/08

网易BUFF脚本

网易BUFF爬取皮肤脚本

// ==UserScript==
// @name         网易buff
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  https://steamcommunity.com/id/BaNaLaLa
// @author       BANALALA
// @match        https://buff.163.com/market/goods?*
// @grant       GM_addStyle
// @grant       GM_xmlhttpRequest
// @grant       GM.setValue
// @grant       GM_setValue
// @grant       GM.getValue
// @grant       GM_getValue
// ==/UserScript==

(function() {
    try{
        var date_a=[
            {"content":"宝石杀猪","price":"1218","wear":"0.06","imgurl":"https://g.fp.ps.netease.com/market/file/5aa65e9869b21aec5b75cf75ZP1jc0QA","url":"https://buff.163.com/market/goods?goods_id=42818&from=market#tab=selling&page_num=4","highwear":false},
            {"content":"锈爪","price":"740","wear":"0.8","imgurl":"","url":"https://buff.163.com/market/goods?goods_id=43023&from=market#tab=selling","highwear":true},
            {"content":"锈9","price":"545","wear":"0.8","imgurl":"","url":"https://buff.163.com/market/goods?goods_id=43117&from=market#tab=selling","highwear":true},
            {"content":"锈刺","price":"440","wear":"0.8","imgurl":"","url":"https://buff.163.com/market/goods?goods_id=42415&from=market#tab=selling","highwear":true},
            {"content":"猎杀大理石","price":"970","wear":"0.8","imgurl":"","url":"https://buff.163.com/market/goods?goods_id=42926&from=market#tab=selling","highwear":false}
        ]//想要购买的皮肤内容//{"content":"什么皮肤(随便写主要是往微信上发信息提示)","price":"价格(250.55)","wear":"磨损(0.01000)","imgurl":"网易buff上的图片地址 主要是多普勒用得到","url":"皮肤地址","highwear":"是否要高磨(true false)"}
        var date_b=[
            {"wear":"0.03389853239059448"},
            {"wear":"0.03125254809856415"}
        ]//屏蔽某几条 因为磨损都是唯一的 用磨损来判断
        var no=GM_getValue("no");//取得皮肤内容的第几条
        if(no==undefined){//防止第一次执行没有数据
            no=0
            GM_setValue("no",no);
        }
        var content=date_a[no].content;
        var price=date_a[no].price;
        var wear=date_a[no].wear;
        var imgurl=date_a[no].imgurl;
        var url=date_a[no].url;
        var highwear=date_a[no].highwear;
        //==============================================================================
        xx_a();
        function xx_a(){
            console.log($(".list_tb_csgo").length);
            if($(".list_tb_csgo").length=1){//判断皮肤列表是否加载上
                setTimeout(get_a,1600);//加载上了就执行主要方法
            }else{
                setTimeout(xx_a,1000);
            }
        }

        function get_a(){
            $("tr").each(function(index){//遍历tr皮肤列表
                var price_temp=$(this).find(".t_Left").find(".f_Strong").text();//取一下tr的长度
                if(price_temp.length!=0){//判断是否有数据,防止为空
                    var price_=$(this).find(".t_Left").find(".f_Strong").text();//寻找价格
                    var imgurl_=$(this).find("td").find("div").find("img").attr("src");//寻找皮肤图案,主要是多普勒的判断
                    var wear_=$(this).find("td").find("div").find("div").find("div").text();//磨损

                    price_=ClearBr(price_);//金额的转换
                    price_=parseFloat(price_.split("¥")[1]);//金额的转换
                    wear_=parseFloat(wear_.split("磨损: ")[1])//磨损的转换
                    console.log("价格:"+price_);
                    console.log("磨损:"+wear_);

                    var raly=true; //屏蔽某几条 因为磨损都是唯一的 用磨损来判断的开关
                    for(var key in date_b){//遍历查找这个磨损
                        if(ClearBr(""+wear_)==ClearBr(""+date_b[key].wear)){//如果有
                            raly=false;
                        }
                    }
                    if(raly==true){ //判断开关
                        if(price_<=price){//判断价格
                            if(highwear==true){//判断是否要买高磨
                                if(wear_>=wear){//判断磨损
                                    if(imgurl==""){//这里主要判断多普勒是否是宝石啥的
                                        test(price_,content,wear_);
                                    }else{
                                        if(imgurl_==imgurl){//这里主要判断多普勒是否是宝石P1234啥的
                                            test(price_,content,wear_);
                                        }
                                    }
                                }
                            }else{
                                if(wear_<=wear){
                                    if(imgurl==""){
                                        test(price_,content,wear_);
                                    }else{
                                        if(imgurl_==imgurl){
                                            test(price_,content,wear_);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            });
            setTimeout(re,6000);
        }
        function re(){
            var i=0
            for(i;i<date_a.length;i++){
                if(date_a[i].url==location.href){//遍历一下当前访问的是第几条皮肤内容
                    break;
                }
            }
            if(i<date_a.length-1){//防止皮肤内容的数组越界
                i++;//加1,设置下次访问皮肤内容下标
                GM_setValue("no",i);
            }else{
                i=0;//置0,重新开始
                GM_setValue("no",i);
            }
            if(date_a[i].url==location.href){//皮肤内容只有1条时候,这个还要判断一下 当前页location.replace(location.href)不管用
                location.reload();
            }else{
                location.replace(date_a[i].url);
            }

        }
        function test(money,content,wear){
            console.log("有一把"+content+"的价格是"+money);
            GM_xmlhttpRequest({
                method : "GET",
                headers: {"Accept": "application/json"},
                url : "https://sc.ftqq.com/SCU14566T8648af5164bb23034b1c2bff405181c059f13a7de0351.send?text="+content+"&desp="+"磨损:"+wear+"价格:"+money,
                onload : function (response) {
                    console.log(response.Reponsetext);
                }
            });
        }
        function ClearBr(key) {
            key = key.replace(/\s+/g, "");
            key = key.replace(/<\/?.+?>/g,"");
            key = key.replace(/[\r\n]/g, "");
            return key;
        }
    }catch(err){
        GM_setValue("no",0);
        location.reload();
    }
})();
Last modification:August 16th, 2018 at 01:46 pm
If you think my article is useful to you, please feel free to appreciate

Leave a Comment