Greasy Fork

天龙畅易阁扫描角色脚本

扫描稀有道具,坐骑,时装,珍兽

目前为 2020-09-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         天龙畅易阁扫描角色脚本
// @namespace    http://tampermonkey.net/
// @require      https://cdn.bootcss.com/jquery/2.2.4/jquery.js
// @version      0.2.2
// @description  扫描稀有道具,坐骑,时装,珍兽
// @author       You
// @match        http://tl.cyg.changyou.com/goods/char_detail*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // Your code here...

    let dataIdNameObj = {}


    let charStr = JSON.stringify(charObj);

    let xiyouObj = {}
    init();
    console.log('------------------------------')
    console.log('角色:'+ charObj.charName)
    let infoArr = [];
    // 扫描稀有道具
    for (let name in xiyouObj) {
        let info = '';
        for (let string of xiyouObj[name]) {
            if (charStr.indexOf(string) != -1) {
                info = name + "-" + string;
                infoArr.push(info);
            }
        }

    }
    // 扫描稀有道具
    infoArr.push.apply(infoArr,scanYiFu());
    // 扫描资质超过4000的珍兽
    infoArr.push.apply(infoArr,scanPetList());
    console.log('------------------------------',infoArr)
    // 扫描到的稀有道具插入页面中
    let ul = document.createElement('ul')
    ul.class = "info-list";
    let total_li = $('<li>角色:'+ charObj.charName +' 稀有道具数量:'+ infoArr.length +'</li>');
    $(ul).append(total_li)
    for(let info of infoArr) {
        let infoStr = '发现角色下有:'+info;
        let li = document.createElement('li')
        let newContent = document.createTextNode(infoStr);
        // 添加文本节点 到这个新的 div 元素
        li.appendChild(newContent);
        ul.appendChild(li)
    }
    let goods_info = document.getElementsByClassName("goods-info")[0];
    goods_info.appendChild(ul)

    function init(){
        console.log("加载稀有道具列表")

        // 稀有装备
        let zhuangbei = ["重楼肩","重楼戒","重楼玉","重楼链"];
        // 稀有坐骑
        let zuoqiArr = ["沧澜羽翼","金羽","梦灵仙驹","青翼战龙","添福锦鳞","水碧飞鸢","绒雪神牛","黑天马","紫电","月白龙马","四喜送鲤台",
            "绝云焱龙","熔岩魔犀","绛紫飞鸢","梦幻仙驹","霸世羽龙","鹊暝墨羽","鹊歌锦羽","绮梦蝶","霞上仙","炎羽","乌夜兮游缰","坠风莲","云水叠"];
        // 稀有时装
        let yifuArr =   ["龙凤呈祥","龙凤遥相倚","锦衣醉画","枭龙霸铠","虎啸雄装","炎狼尊袍","鲤戏澜芳","辰渊云蕊","霓裳羽衣","碧景琉璃",
            "梦华录","惜君青玉裳","瑞鹤集","红泪多","笑红尘","虹蝉锦装","愿君共白首","羽衣何翩跹","熹年画中人","上元清嘉景","缇骑照玉京"]
        // 稀有幻世武器
        let huanshiArr = ["绿绮"]
        xiyouObj = {
            "装备":zhuangbei,
            "坐骑":zuoqiArr,
            "时装":yifuArr,
            "幻视武器":huanshiArr,
            "稀有道具":["移骨丹"]
        }
    }

    // 扫描稀有时装
    function scanYiFu(){
        // 获取装备,道具描述信息
        dataIdNameObj = {
            '凤染梧桐':'时装-仙侣情缘【凤染梧桐风格】',
            '紫绶仙尊风格':'时装-仙侣情缘【紫绶仙尊风格】',
            '朱颜风格':'时装-银霏染月【朱颜风格】',
            '金粉世家':'时装-墨羽潜幽【金粉世家风格】',
            '檀粉风格':'时装-锦绣游仙【檀粉风格】'
        }
        let dataIdArr = [];
        for (let key in dataIdNameObj){
            dataIdArr.push(key)
        }
        // 扫描到的稀有道具
        let xiyouDataArr = [];
        $("script[id]").each(function(){
            let type = $(this).attr("type");
            let id = $(this).attr("id");
            if("text/tips" == type && /^[0-9]*$/.test(id) ) {
                let desc = $(this).html();
                for (let string of dataIdArr) {
                    if(desc.indexOf(string) != -1){
                        xiyouDataArr.push(dataIdNameObj[string])
                    }
                }

            }

        });
        return xiyouDataArr;
    }

    // 扫描珍兽
    function scanPetList() {
        let xiyouPetList = [];
        for (let i = 0; i < charObj.petList.length; i++) {
            let pet = charObj.petList[i];
            let petInfo = "珍兽-" + pet.petVarLevelExplain;
            // 获取各项资质,其中一项资质超过4000,就展示出来
            if (pet.strPerception >= 4000) {
                petInfo += "【力量资质"+pet.strPerception+"】";
            }
            if (pet.sprPerception >= 4000) {
                petInfo += "【灵气资质"+pet.sprPerception+"】"
            }
            if (pet.conPerception >= 4000) {
                petInfo += "【体力资质"+pet.conPerception+"】"
            }
            if (pet.comPerception >= 4000) {
                petInfo += "【定力资质"+pet.comPerception+"】"
            }
            if (pet.dexPerception >= 4000) {
                petInfo += "【身法资质"+pet.dexPerception+"】"
            }
            // 七八级变异等级
            if (pet.petVarLevel >= 7) {
                petInfo += "【"+ pet.petVarLevel +"级变异】";
            }
            if (petInfo.indexOf("【") != -1) {
                xiyouPetList.push(petInfo);
            }
        }
        return xiyouPetList;
    }
})();