Greasy Fork

天龙畅易阁扫描角色脚本

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

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

// ==UserScript==
// @name         天龙畅易阁扫描角色脚本
// @namespace    http://tampermonkey.net/
// @require      https://cdn.bootcss.com/jquery/2.2.4/jquery.js
// @version      0.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());
    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;
    }
})();