DLD Items Finder

help to find item by searching part of its name

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         DLD Items Finder
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  help to find item by searching part of its name
// @author       You
// @include      https://dld.qzapp.z.qq.com/qpet/cgi-bin/phonepk?*cmd=store*
// @include      https://dld.qzapp.z.qq.com/qpet/cgi-bin/phonepk?*cmd=store&store_type=0&page=*
// @require      https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
// @grant        none
// ==/UserScript==

function request(url){
    $.ajaxSettings.async = false;
    let retData;
    $.get(url, function(data){
        retData = data;
    });
    return retData;
};

(function() {
    'use strict';
    var items = {"徽章符文石":"3683","小体力(10点)":"3001","小活力药水":"3386","贡献药水":"3038","大体力(30点)":"3003","神来拳套":"3028","经验药水":"3014","风之息(赠)":"3022","挑战书":"3040","神来拳套(赠)":"3030","迅捷珠(赠)":"3021","被动经验药水":"3043","大力丸(赠)":"3020","剑君魂珠1级":"4001","移魂符":"3102","无字天书":"3374","帅帅魂珠1级":"4031","阅历羊皮卷":"3176","活血散":"3004","玄铁扇骨":"7001","还童天书":"3101","大型武器符文石":"3655","斗神符":"3090","征战书":"3111","巅峰之战二等勋章":"3487","孙子兵法":"3477","贡献小笼包":"3356","一级幸运石":"6020","大经验药水":"3015","迅捷珠":"3017","抽奖卡":"3217","新春快乐礼包":"5110","修为丹":"5088","锋利的狼牙":"3925","粗壮的牛角":"3915","减伤药水":"3399","尖锐的铁器":"3880","沧桑的兽骨":"3873","坚固的砥石":"3788","稳固的磐石":"3864","还魂丹":"3089","活血散*百":"3005","经验药水7天":"3019","青铜星尘":"3417","塔罗牌":"3916","金疮药":"3006","大力丸":"3016","寻斗符":"3076","风之息":"3018","宝石金戒":"3411","被动经验7天":"3029","突破石":"5153","力量洗刷刷":"3023","敏捷洗刷刷":"3024","速度洗刷刷":"3025","大色魔30天":"3143","佣兵天赋丹":"5391","贡献叉烧包":"3503","门派引荐书":"3884","元婴敏捷果":"5177","土豪金":"3382","菜菜魂珠2级":"4012","河图洛书":"5435","大金疮药":"3398","教主魂珠1级":"4061","翡翠银戒":"3412","永恒紫钻":"3410","祈福令":"3565","元婴经验果":"5313","淬火结晶":"3872","时之沙":"3863","神将潘达1天":"5772","剑君7天":"3117","乐斗残卷":"5707","巅峰之战一等勋章":"3488","剑君魂珠碎片":"3366","月影魂珠碎片":"3368","追魂锁链":"3074","三彩水晶石":"3886","丐帮堂主7天":"3900","孟婆汤":"3037","程管30天":"3141","贡献药水*百":"3039","黄鸟碎片":"5157","菜菜7天":"3115","烛龙碎片":"5156","符石水晶":"5461","中型武器符文石":"3656","门派战书":"3662","易经八卦":"5436","免战牌":"3216","神将沙漏":"5874","熔炼乌金":"5464","源大侠7天":"3127","情人草":"3056","温良恭的信物":"3549","吕青橙的信物":"3548","蔡八斗的信物":"3547","银戒指":"3058","饕餮碎片":"5155","门派强化书":"3882","姜公锦囊":"3064","武魂符":"5704","神装之灵":"3910","夔牛碎片":"5154","软猥金丝":"3574","程管锦囊":"3070","新手小王子锦囊 ":"3180","盗圣锦囊":"3213","四姑娘锦囊":"3069","帅帅锦囊":"3063","四灵魂石":"3924","武穆遗书":"3670","白银星尘":"3418","神秘锦囊":"3042","大色魔锦囊":"3068","俊猴王锦囊":"3055","月敏锦囊":"3045","教主锦囊":"3062","剑君锦囊":"3044","月璇锦囊":"3065","大色魔7天":"3142","四姑娘7天":"3157","马大师7天":"3148","曾小三锦囊":"3182","神将碎片宝箱":"5878","百炼钢":"3871","投掷武器符文石":"3658","门派高香":"3887","转转券":"3921","还童卷轴":"3100","血灵魂珠2级":"4042","传功符":"3181","羊魔王锦囊":"3061","幸运石礼盒":"3447","灵兽碎片礼包":"5299","月璇魂珠碎片":"3369","血灵魂珠碎片":"3370","帅帅魂珠碎片":"3367","鹅王锦囊":"3212","牙牙形象卡365天":"6247","神兵原石":"3573","真黄金卷轴":"5089","奥秘元素":"3923","小型武器符文石":"3657","斗魂符":"5706","剑君魂珠2级":"4002","奔流气息":"3636","教主魂珠3级":"4063","菜菜魂珠碎片":"3365","黄金星尘":"3419","月敏30天":"3120","斗灵石-火":"6299","斗灵石-土":"6300","长长久久":"6305","菜菜30天":"3116","剑君30天":"3118","斗灵石-木":"6297","斗灵石-水":"6298","超值传功符礼包":"3581","葵花宝典":"3060","竞技场入场券":"3572","月影魂珠3级":"4053","斗灵石-金":"6296","黄金卷轴":"3036","回声之影30天":"3177","邪神30天":"3132","1级紫黑玉":"3728","凤凰羽毛":"3575","元婴飞仙果":"6212","马大师锦囊":"3067","源大侠锦囊":"3066","上古玉髓":"3631","悟性丹":"3099","神魔残卷":"5152","染血的羊皮":"3789","月影魂珠2级":"4052","教主魂珠碎片":"3478","教主魂珠2级":"4062","月璇魂珠2级":"4022","帅帅魂珠2级":"4032","魂珠碎片宝箱":"3371","一等武林宝箱":"3047","炼气石":"3881","佣兵碎片大宝箱":"5877","千年寒铁":"3659","佣兵碎片中宝箱":"5876","优惠券":"3783","三级幸运石":"6022","二级幸运石":"6021","潜能果实":"3576","中体力":"3002","境界丹":"5087","破碎的铠甲":"3909","四色补天石":"3888","月璇魂珠1级":"4021","月影魂珠1级":"4051","血灵魂珠1级":"4041","经验木简":"3178","野生火鸡":"3606","金兰香":"3087","小王子30天":"3154","月敏7天":"3119","程管7天":"3140","校霸7天":"3146","羊魔王30天":"3114","秋风扇骨":"7000","七级幸运石":"6026","烤架":"3607","龙珠盒子":"3599","许愿卡碎片":"3654","俊猴王30天":"3145","古铜钥匙":"3474","翡翠钥匙":"3475","春":"5103","快":"5104","新":"5102","乐":"5105","月影7天":"3133","玛瑙石碎片":"3695","星石兑换券":"3917","帅帅7天":"3125","1级狂暴石":"5316","月璇魂珠3级":"4023","帅帅魂珠4级":"4034","神秘礼盒":"3400","2级迅捷石":"3705","剑君魂珠4级":"4004","桃木扇骨":"7002","血灵魂珠4级":"4044","3级迅捷石":"3706","2级玛瑙石":"3697","1级日曜石":"3688","1级迅捷石":"3704","1级玛瑙石":"3696","教主魂珠4级":"4064","华山堂主7天":"3897","迅捷珠迷你装":"3220","血灵魂珠3级":"4043","月影魂珠4级":"4054","菜菜魂珠1级":"4011","斗技符小宝箱":"5710","2级狂暴石":"5317","剑君魂珠3级":"4003","1级神愈石":"5324","神秘精华":"3567","战魂符":"5705","四级幸运石":"6023","2级翡翠石":"3721","真体力(60点)":"3041","活力药水":"3105","夺宝卡":"5408","斗技符大宝箱":"5712","2级日曜石":"3689","资源补给箱":"3671","2级神愈石":"5325","阅历卷宗":"3381","生命洗刷刷":"3103","1级翡翠石":"3720","2级紫黑玉":"3729","菜菜魂珠4级":"4014","菜菜魂珠3级":"4013","帅帅魂珠3级":"4033","爆炎7天":"3137","羊魔王内丹":"3201","普通招募券":"5973","高级招募券":"5972","邪神7天":"3131","豚豚形象卡365天":"6248","3级紫黑玉":"3730","二等武林宝箱":"3048","佣兵碎片小宝箱":"5875","夜叉内丹":"3203","血灵7天":"3135","峨眉堂主7天":"3894","3级狂暴石":"5318","3级神愈石":"5326","小木锤":"3257","风之息*百":"3034","明教堂主7天":"3935","帮派战鼓":"3922"};
	window.sessionStorage.setItem("items", JSON.stringify(items));

    let $a = $(`<br><input id="keyword" type="text" onkeypress="if(event.keyCode==13){this.nextElementSibling.click();return false;}"><a id="search">检索</a>`).css("color", "red");
    $(document).on('click', "#search", function(e) {
		let keyword = $("#keyword").val();
        if(!keyword) return;
        for(let key in items){
            if(key.indexOf(keyword) != -1){
                let url = `https://dld.qzapp.z.qq.com/qpet/cgi-bin/phonepk?zapp_uin=&sid=&channel=0&g_ut=1&cmd=owngoods&id=${items[key]}`,
                    pageData = request(url);
                let result = /数量:(\d+)/.exec(pageData),
                    count  = result == null ? "数量:0" : result[0];
                //console.log(count)
                let $aa = $(`<br><a target="_blank" href="${url}">${key}</a><span>${count}</span><a class="useall" data-id="${items[key]}">全部使用</a>`);
                $(this).after($aa)
            };
        };
    }).on('click', ".useall", function(e) {
		let $this = $(this),
            _id = $this.data("id"),
            url = "https://dld.qzapp.z.qq.com/qpet/cgi-bin/phonepk?zapp_uin=&sid=&channel=0&g_ut=1&cmd=use&id=" + _id;
        var timer = setInterval(function(){
            let pageData = request(url);
            if( pageData.indexOf("获得") == -1 || pageData.indexOf("系统繁忙") != -1 || pageData.indexOf("不能被使用") != -1 ){
                clearInterval(timer);
                $this.after("使用完毕");
            }else{
                let result = /获得:([^\d]+)([\d]+)个。/.exec(pageData);
                if( result != null ){
                    let item = result[1].replace("\(", "").replace("\)", ""),
                        $item = $("#"+_id+item);
                    if( $item.length ){
                        $item.text(parseInt($item.text()) + parseInt(result[2]));
                    }else{
                        $this.after(`获得:${item}<span id=${_id+item} style="color:red;">${result[2]}</span>个。`);
                    };
                };
            };
        },200);
        if(!keyword) return;
        for(let key in items){
            if(key.indexOf(keyword) != -1){
                let url = `https://dld.qzapp.z.qq.com/qpet/cgi-bin/phonepk?zapp_uin=&sid=&channel=0&g_ut=1&cmd=owngoods&id=${items[key]}`,
                    pageData = request(url);
                let result = /数量:(\d+)/.exec(pageData),
                    count  = result == null ? "数量:0" : result[0];
                console.log(count)
                let $aa = $(`<br><a target="_blank" href="${url}">${key}</a><span>${count}</span><a class="useall" data-id="${items[key]}">全部使用</a>`);
                $(this).after($aa)
            };
        };
    });
    $("a").last().after($a);
    /*$("a").each(function(index){
		let $this = $(this),
            href = $this.attr("href");
		if(href.indexOf("cmd=owngoods") != -1){
			let _id = /id=(\d+)/.exec(href)[1];
            items[$this.text()] = _id;
            console.log($this.text() + _id)
		};
	});*/

})();