咕咕镇数据采集

咕咕镇数据采集,目前采集技能率、暴击率(采集已关闭)

目前为 2020-08-04 提交的版本,查看 最新版本

// ==UserScript==
// @name         咕咕镇数据采集
// @namespace    https://greasyfork.org/users/448113
// @version      0.5.1
// @description  咕咕镇数据采集,目前采集技能率、暴击率(采集已关闭)
// @author       paraii
// @include      https://www.lv999max.com/*
// @grant        GM_xmlhttpRequest
// @connect      notes.orga.cat
// @connect      www.lv999max.com
// @require      https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @license      MIT License
// ==/UserScript==

function submitData(){
    if(localStorage.length>4&&localStorage.getItem('over')=='1'){
        var meURL = `https://notes.orga.cat/${encodeURI(localStorage.getItem('title')).replace(/%/g, '').replace(/~/g,'7E')}`;
        console.log(meURL);
        GM_xmlhttpRequest({
            method: 'GET',
            url: meURL,
            timeout: 30000,
            headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
            onload: response => {
                let text = response.responseText.match(/content">([\s\S]*)<\/text/)[1];
                if(text.length==0){
                    text='{"1-50":{"MU":[0],"ZHU":[0],"DENG":[0],"SHOU":[0]},"51-100":{"MU":[0],"ZHU":[0],"DENG":[0],"SHOU":[0]},"101-":{"MU":[0],"ZHU":[0],"DENG":[0],"SHOU":[0]}}'
                }else{
                    text=text.replace(/&quot;/g,'"');
                }

                let json = JSON.parse(text);
                let pk_i = 0;
                while(localStorage.getItem(`pk${pk_i}`)!=null){
                    let a = localStorage.getItem(`pk${pk_i}`).split(',');
                    let n = a.shift();
                    for(let j = 1; j<a.length; j++){
                        a[j] = +a[j];
                    }
                    if(a[3]<51){
                        json['1-50'][n].push(a);
                    }
                    else if(a[3]<101&&a[3]>50){
                        json['51-100'][n].push(a);
                    }
                    else{
                        json['101-'][n].push(a);
                    }
                    pk_i++;
                }

                text = JSON.stringify(json);
                GM_xmlhttpRequest({
                    method: 'POST',
                    url: meURL,
                    timeout: 30000,
                    headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
                    data: `text=${text}`,
                    onload: response => {
                        let atrr = localStorage.getItem('attribute');
                        let na = localStorage.getItem('cardName');
                        let ti = localStorage.getItem('title');
                        localStorage.clear();
                        localStorage.setItem('attribute',atrr);
                        localStorage.setItem('cardName',na);
                        localStorage.setItem('title',ti);
                    }
                });
            }
        });
        return 1;
    }else{
        return 0;
    }
}


(function() {
    'use strict'
    if(localStorage.getItem('attribute')==null&&localStorage.getItem('cardName')==null){
        localStorage.setItem('attribute',0);
        localStorage.setItem('cardName',0);
    }
    //     if(localStorage.getItem('pk99')!=null&&localStorage.getItem('title')!=null){ //超过100条战斗自动提交
    //         localStorage.setItem('over', 1);
    //         try{
    //             //submitData();
    //         }catch(err){
    //             console.log(err);
    //         }
    //         localStorage.setItem('over', 0);
    //         let nameURL = `https://notes.orga.cat/gugudataname`;
    //         GM_xmlhttpRequest({
    //             method: 'GET',
    //             url: nameURL,
    //             timeout: 30000,
    //             headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
    //             onload: response => {
    //                 let text = response.responseText.match(/content">([\s\S]*)<\/text/)[1];
    //                 let list = text.split(',');
    //                 if(list.indexOf(localStorage.getItem('title'))==-1){
    //                     list.push(localStorage.getItem('title'));
    //                     text = list.join(',');
    //                     GM_xmlhttpRequest({
    //                         method: 'POST',
    //                         url: nameURL,
    //                         timeout: 30000,
    //                         headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
    //                         data: `text=${text}`,
    //                         onload: response => {
    //                             let atrr = localStorage.getItem('attribute');
    //                             let na = localStorage.getItem('cardName');
    //                             let ti = localStorage.getItem('title');
    //                             localStorage.clear();
    //                             localStorage.setItem('attribute',atrr);
    //                             localStorage.setItem('cardName',na);
    //                             localStorage.setItem('title',ti);
    //                         }
    //                     });
    //                 }
    //             }
    //         });
    //     }

    var attribute = new Array();

    if(window.location.pathname=='/fyg_card.php'){
//         let btn2 = document.createElement('button');
//         let span2 = document.createElement('span');
//         let btnc1 = document.createElement('button');
//         let cardNameNode = 0;
//         function updateCard(){
//             span2.innerHTML = '读取中...';
//             attribute.splice(0,attribute.length);
//             for(let i=1;i<7;i++){
//                 attribute.push(document.getElementById(`sjj${i}`).innerText);
//             }
//             localStorage.setItem('attribute',attribute.join(','));
//             localStorage.setItem('cardName',cardNameNode.innerText);
//             if(localStorage.getItem('cardName')==''){localStorage.setItem('cardName',null);}
//             span2.innerHTML = `    当前卡片:${localStorage.getItem('cardName')}(${localStorage.getItem('attribute')})`;
//         }

//         span2.innerHTML = `    当前卡片:${localStorage.getItem('cardName')}(${localStorage.getItem('attribute')})`;
//         btn2.innerHTML = '手动读取';
//         btn2.onclick = updateCard;
//         btnc1.innerHTML = '导出计算器';
//         btnc1.onclick = ()=>{
//             $('.pop_main').show()
//             $('.pop_con').css({'top':0,'opacity':0})
//             $('.pop_con').animate({'top':'50%','opacity':1})
//             let text = $('.pop_text');
//             switch(localStorage.getItem('cardName')){
//                 case '琳':
//                     text[0].innerText = `LIN ${cardNameNode.parentNode.children[1].innerText.substr(3)} ${cardNameNode.parentNode.children[3].innerText[0]}`;
//                     text[1].innerText = `${localStorage.getItem('attribute').replace(/,/g,' ')}`;
//                     break;
//                 case '艾':
//                     text[0].innerText = `AI ${cardNameNode.parentNode.children[1].innerText.substr(3)} ${cardNameNode.parentNode.children[3].innerText[0]}`;
//                     text[1].innerText = `${localStorage.getItem('attribute').replace(/,/g,' ')}`;
//                     break;
//                 case '默':
//                     text[0].innerText = `MO ${cardNameNode.parentNode.children[1].innerText.substr(3)} ${cardNameNode.parentNode.children[3].innerText[0]}`;
//                     text[1].innerText = `${localStorage.getItem('attribute').replace(/,/g,' ')}`;
//                     break;
//                 case '梦':
//                     text[0].innerText = `MENG ${cardNameNode.parentNode.children[1].innerText.substr(3)} ${cardNameNode.parentNode.children[3].innerText[0]}`;
//                     text[1].innerText = `${localStorage.getItem('attribute').replace(/,/g,' ')}`;
//                     break;
//             }
//         }
//         let p = document.getElementsByClassName('panel panel-primary')[1];
//         p.insertBefore(span2,p.children[0]);
//         p.insertBefore(btn2,p.children[0]);
//         p.insertBefore(btnc1,p.children[0]);

//         let d = document.createElement('div');
//         d.id = 'alert';
//         d.innerHTML = '<div class="pop_main">\n<div class="pop_con">\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<a href="#">×</a>\n</div>\n<div class="mask"></div>\n</div>';

//         p.insertBefore(d,p.children[0]);
//         $('.pop_main').hide();
//         $('.pop_con a').click(()=>{
//             $('.pop_con').animate({'top':0,'opacity':0},()=>{
//                 $('.pop_main').hide()
//             })
//         })

//         let load1=0,load2=0;
//         let observer1 = new MutationObserver(()=>{
//             load1=1;
//             document.getElementsByClassName('btn btn-block btn-lg btn-warning')[0].addEventListener('click', updateCard);
//             if(load1&&load2){
//                 updateCard();
//                 load1=0;load2=0;
//             }
//         });
//         observer1.observe(document.getElementById('mystata'), {childList: true, characterData: true});
//         let observer2 = new MutationObserver(()=>{
//             load2=1;
//             cardNameNode = document.getElementById('carding').children[0].children[0];
//             if(load1&&load2){
//                 updateCard();
//                 load1=0;load2=0;
//             }
//         });
//         observer2.observe(document.getElementById('carding'), {childList: true});
    }
    else if(window.location.pathname=='/fyg_equip.php'){
        let btnc1 = document.createElement('button');
        btnc1.innerText = '导出计算器';
        btnc1.onclick = ()=>{
            $('.pop_main').show()
            $('.pop_con').css({'top':0,'opacity':0})
            $('.pop_con').animate({'top':'50%','opacity':1})

        }

        var observer = new MutationObserver(()=>{
            let page = document.getElementsByClassName('nav nav-secondary nav-justified')[0].children;
            let index = 0;
            for(let i=0;i<4;i++){
                if(page[i].className=='active'){
                    index = i;
                }
            }
            switch(index){
                case 0:
                    console.log(0);
                    btnc1.onclick = ()=>{
                        $('.pop_main').show()
                        $('.pop_con').css({'top':0,'opacity':0})
                        $('.pop_con').animate({'top':'50%','opacity':1})
                        try{
                            d.innerHTML = '<div class="pop_main">\n<div class="pop_con">\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">Bag:</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text">/</div>\n<div class="pop_text_tip" style="color:#F00">*装备若有神秘请把最后一位0改成1</div>\n<a href="#">×</a>\n</div>\n<div class="mask"></div>\n</div>';
                            $('.pop_con a').click(()=>{
                                $('.pop_con').animate({'top':0,'opacity':0},()=>{
                                    $('.pop_main').hide()
                                })
                            })
                            $('.pop_main').show()
                            $('.pop_con').css({'top':0,'opacity':0})
                            $('.pop_con').animate({'top':'50%','opacity':1})
                            let text = $('.pop_text');
                            let data = new Array();
                            let bagdata = new Array();
                            let equip = document.getElementsByClassName('fyg_tc')[3];
                            console.log(equip);
                            for(let i=0;i<4;i++){
                                let atrr = equip.children[i].getAttribute('data-content').match(/>[0-9]+%</g);
                                let title = equip.children[i].getAttribute('data-original-title');
                                let lv = title.match(/>[0-9]+</g)[0];
                                let name = title.substr(title.lastIndexOf('>')+1);
                                let mys = 0;
                                switch(name[name.length-1]){
                                    case '杖':name='STAFF';break;
                                    case '弓':name='BOW';break;
                                    case '剑':name='SWORD';break;
                                    case '刃':name='BLADE';break;
                                    case '套':name='GLOVES';break;
                                    case '环':name='BRACELET';break;
                                    case '袍':name='CLOAK';break;
                                    case '巾':name='SCARF';break;
                                    default:
                                        switch(name[name.length-2]){
                                            case '布':name='CLOTH';break;
                                            case '皮':name='LEATHER';break;
                                            case '铁':name='PLATE';break;
                                            case '重':name='THORN';break;
                                        }

                                }
                                data.push(new Array(name,lv.replace('<','').replace('>',''),atrr[0].replace('%','').replace('<','').replace('>',''),atrr[1].replace('%','').replace('<','').replace('>',''),atrr[2].replace('%','').replace('<','').replace('>',''),atrr[3].replace('%','').replace('<','').replace('>',''),mys));
                            }
                            text[0].innerText = `${data[0].join(' ')}`;
                            text[1].innerText = `${data[1].join(' ')}`;
                            text[2].innerText = `${data[2].join(' ')}`;
                            text[3].innerText = `${data[3].join(' ')}`;

                            let bag = document.getElementById('backpacks').children;
                            if(bag.length>0){
                                for(let i=0;i<bag.length;i++){
                                    let atrr = bag[i].getAttribute('data-content').match(/>[0-9]+%</g);
                                    let title = bag[i].getAttribute('data-original-title');
                                    let lv = title.match(/>[0-9]+</g)[0];
                                    let name = title.substr(title.lastIndexOf('>')+1);
                                    let mys = 0;
                                    switch(name[name.length-1]){
                                        case '杖':name='STAFF';break;
                                        case '弓':name='BOW';break;
                                        case '剑':name='SWORD';break;
                                        case '刃':name='BLADE';break;
                                        case '套':name='GLOVES';break;
                                        case '环':name='BRACELET';break;
                                        case '袍':name='CLOAK';break;
                                        case '巾':name='SCARF';break;
                                        default:
                                            switch(name[name.length-2]){
                                                case '布':name='CLOTH';break;
                                                case '皮':name='LEATHER';break;
                                                case '铁':name='PLATE';break;
                                                case '重':name='THORN';break;
                                            }

                                    }
                                    bagdata.push(new Array(name,lv.replace('<','').replace('>',''),atrr[0].replace('%','').replace('<','').replace('>',''),atrr[1].replace('%','').replace('<','').replace('>',''),atrr[2].replace('%','').replace('<','').replace('>',''),atrr[3].replace('%','').replace('<','').replace('>',''),mys));
                                }
                            }
                            for(let i =0;i<bagdata.length;i++){
                                text[5+i].innerText =`${bagdata[i].join(' ')}`;
                            }
                        }catch(err){console.log(err);}
                    }

                    break;
                case 1:
                    console.log(1);
                    btnc1.onclick = ()=>{};
                    break;
                case 2:
                    console.log(2);
                    btnc1.onclick = ()=>{
                        try{
                            d.innerHTML = '<div class="pop_main">\n<div class="pop_con">\n<div class="pop_text">0</div>\n<a href="#">×</a>\n</div>\n<div class="mask"></div>\n</div>';
                            $('.pop_con a').click(()=>{
                                $('.pop_con').animate({'top':0,'opacity':0},()=>{
                                    $('.pop_main').hide()
                                })
                            })
                            $('.pop_main').show()
                            $('.pop_con').css({'top':0,'opacity':0})
                            $('.pop_con').animate({'top':'50%','opacity':1})
                            let text = $('.pop_text');
                            let aura = document.getElementsByClassName('btn btn-primary');
                            let data = new Array();
                            data.push(aura.length);

                            for(let i=0;i<aura.length;i++){
                                let t = aura[i].innerText;
                                //console.log(t);
                                switch(t[0]){
                                    case '启':
                                        switch(t[3]){
                                            case '誓':data.push('SHI');break;
                                            case '心':data.push('XIN');break;
                                            case '风':data.push('FENG');break;
                                        }
                                        break;
                                    case '破':
                                        switch(t[1]){
                                            case '壁':data.push('BI');break;
                                            case '魔':data.push('MO');break;
                                        }
                                        break;
                                    case '伤':data.push('SHANG');break;
                                    case '精':data.push('SHEN');break;
                                    case '铁':data.push('CI');break;
                                    case '沸':data.push('FEI');break;
                                    case '波':data.push('BO');break;
                                    case '飓':data.push('JU');break;
                                }
                            }
                            text[0].innerText = `${data.join(' ')}`;
                            //$('.pop_main').hide();

                        }catch(err){
                            console.log(err);
                        }
                    }
                    break;
                case 3:
                    console.log(3);
                    btnc1.onclick = ()=>{
                        try{
                            d.innerHTML = '<div class="pop_main">\n<div class="pop_con">\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<a href="#">×</a>\n</div>\n<div class="mask"></div>\n</div>';
                            $('.pop_con a').click(()=>{
                                $('.pop_con').animate({'top':0,'opacity':0},()=>{
                                    $('.pop_main').hide()
                                })
                            })
                            $('.pop_main').show()
                            $('.pop_con').css({'top':0,'opacity':0})
                            $('.pop_con').animate({'top':'50%','opacity':1})
                            let text = $('.pop_text');
                            let cardInfo = document.getElementsByClassName('text-info fyg_f18')[0].innerText

                            GM_xmlhttpRequest({
                                method: 'POST',
                                url: `https://www.lv999max.com/fyg_read.php`,
                                headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
                                data: 'f=5',
                                onload: response => {
                                    let halo = response.responseText.match(/( [0-9]/)[0].replace('( ','');
                                    switch(cardInfo[0]){
                                        case '琳':
                                            text[0].innerText = `LIN ${cardInfo.match(/([0-9]+/)[0].replace('(','')} ${halo}`;
                                            text[1].innerText = `${document.getElementById('sjll').getAttribute('value')} ${document.getElementById('sjmj').getAttribute('value')} ${document.getElementById('sjzl').getAttribute('value')} ${document.getElementById('sjtp').getAttribute('value')} ${document.getElementById('sjjs').getAttribute('value')} ${document.getElementById('sjyz').getAttribute('value')}`;
                                            break;
                                        case '艾':
                                            text[0].innerText = `AI ${cardInfo.match(/([0-9]+/)[0].replace('(','')} ${halo}`;
                                            text[1].innerText = `${document.getElementById('sjll').getAttribute('value')} ${document.getElementById('sjmj').getAttribute('value')} ${document.getElementById('sjzl').getAttribute('value')} ${document.getElementById('sjtp').getAttribute('value')} ${document.getElementById('sjjs').getAttribute('value')} ${document.getElementById('sjyz').getAttribute('value')}`;
                                            break;
                                        case '默':
                                            text[0].innerText = `MO ${cardInfo.match(/([0-9]+/)[0].replace('(','')} ${halo}`;
                                            text[1].innerText = `${document.getElementById('sjll').getAttribute('value')} ${document.getElementById('sjmj').getAttribute('value')} ${document.getElementById('sjzl').getAttribute('value')} ${document.getElementById('sjtp').getAttribute('value')} ${document.getElementById('sjjs').getAttribute('value')} ${document.getElementById('sjyz').getAttribute('value')}`;
                                            break;
                                        case '梦':
                                            text[0].innerText = `MENG ${cardInfo.match(/([0-9]+/)[0].replace('(','')} ${halo}`;
                                            text[1].innerText = `${document.getElementById('sjll').getAttribute('value')} ${document.getElementById('sjmj').getAttribute('value')} ${document.getElementById('sjzl').getAttribute('value')} ${document.getElementById('sjtp').getAttribute('value')} ${document.getElementById('sjjs').getAttribute('value')} ${document.getElementById('sjyz').getAttribute('value')}`;
                                            break;
                                    }
                                }
                            });
                        }catch(err){console.log(err);}
                    }
                    break;
            }
        });

        observer.observe(document.getElementById('backpacks'), {childList: true, characterData: true});

        let p = document.getElementsByClassName('panel panel-primary')[1];
        p.insertBefore(btnc1,p.children[0]);

        let d = document.createElement('div');
        d.id = 'alert';
        d.innerHTML = '<div class="pop_main">\n<div class="pop_con">\n<div class="pop_text">0</div>\n<a href="#">×</a>\n</div>\n<div class="mask"></div>\n</div>';
        //'<div class="pop_main">\n<div class="pop_con">\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">Bag:</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<div class="pop_text">0</div>\n<a href="#">×</a>\n</div>\n<div class="mask"></div>\n</div>';

        p.insertBefore(d,p.children[0]);
        $('.pop_main').hide();
        $('.pop_con a').click(()=>{
            $('.pop_con').animate({'top':0,'opacity':0},()=>{
                $('.pop_main').hide()
            })
        })
    }
    else if(window.location.pathname=='/fyg_pk.php'){
        let btn1 = document.createElement('button');
        let btn2 = document.createElement('button');
        let span0 = document.createElement('span');
        span0.innerHTML = '  提交中...';
        span0.className = 'tip';
        //btn1.innerHTML = '正在读取卡片...';
        btn1.innerHTML = '提交数据';
        btn1.onmousedown = ()=>{
            if(btn1.innerText[0]=='提'){
                $('.tip').show();
            }
        };
        btn1.onclick = ()=>{
            if(btn1.innerText[0]=='提'){
                try{
                    alert('数据采集已关闭');
                    $('.tip').hide();
                    localStorage.clear();
                    //                     let npc = document.getElementById('pklist').children;
                    //                     for(let i = 2;i<12;i++){
                    //                         //console.log(npc[o].innerText[0]);
                    //                         if(npc[i].innerText[0]!='已'){
                    //                             localStorage.setItem('over', 0); //未与全部npc战斗
                    //                             alert('未与全部npc战斗,请与全部npc完成战斗后提交')
                    //                             break;
                    //                         }
                    //                         else{
                    //                             localStorage.setItem('over', 1);
                    //                         }
                    //                     }
                    //                     if(submitData()){
                    //                         alert('数据已提交,第一次使用记得把用户名站内发给thewzmath');
                    //                         $('.tip').hide();
                    //                     }
                    //                     else{
                    //                         if(localStorage.length<=4&&localStorage.getItem('over')=='1'){
                    //                             alert('无数据');
                    //                         }
                    //                         $('.tip').hide();
                    //                     }
                }
                catch(err){
                    console.log(err);
                    alert('数据提交失败,请重试');
                    $('.tip').hide();
                }
            }
        };
        btn2.innerText = '清空数据';
        btn2.onclick = ()=>{
            console.log(1);
            if(confirm('确定要清空数据吗?\n*确定后会刷新页面')){
                localStorage.clear();
                window.location.reload();
            }
        }

        let p = document.getElementsByClassName('panel panel-primary')[0];
        p.insertBefore(span0,p.children[0]);
        p.insertBefore(btn1,p.children[0]);
        p.insertBefore(btn2,p.children[0]);
        $('.tip').hide();


//         try{
//             GM_xmlhttpRequest({
//                 method: 'POST',
//                 url: `https://www.lv999max.com/fyg_read.php`,
//                 headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
//                 data: 'f=9',
//                 onload: response => {
//                     try{
//                         var n = response.responseText.match(/>[\u4e00-\u9fa5]</u)[0];
//                         localStorage.setItem('cardName',n.substr(1,n.length-2));
//                     }catch(err){localStorage.setItem('cardName','null');}
//                     GM_xmlhttpRequest({
//                         method: 'POST',
//                         url: `https://www.lv999max.com/fyg_read.php`,
//                         headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'},
//                         data: 'f=4',
//                         onload: response => {
//                             //console.log(response.responseText);
//                             attribute.splice(0,attribute.length);
//                             response.responseText.match(/>(\d+)</g).forEach(item => {
//                                 attribute.push(item.substr(1,item.length-2));
//                             });
//                             attribute.shift();
//                             localStorage.setItem('attribute',attribute.join(','));
//                             if(localStorage.getItem('cardName')!='0'&&localStorage.getItem('attribute')!='0'){
//                                 //alert('卡片读取完成');
//                                 btn1.innerHTML = '提交数据';

//                                 console.log(localStorage);

//                                 var targetNode = document.getElementById('pk_text');
//                                 var config = {childList: true};
//                                 // 当节点发生变化时的需要执行的函数
//                                 var callback = function(mutationsList, observer) {
//                                     var isPk = 0;
//                                     for(let mutation of mutationsList) {
//                                         if (mutation.type == 'childList') {
//                                             //console.log('new pk');
//                                             isPk = 1;
//                                             //console.log(targetNode.firstChild);

//                                         }
//                                     }

//                                     if(isPk){
//                                         var infoList = targetNode.firstChild.children;
//                                         //infoList: [0]名字,[1]初始血盾,[2]第一回合{左方信息,右方信息,左方血盾,右方血盾},[3]第二回合{..} ...[end]结果
//                                         var npcTitle = '';
//                                         var npcName = '';
//                                         var npcLv = '';
//                                         var npcRate = 0;
//                                         var npcSKL = '';
//                                         var meName = 'null';
//                                         var meSKL = 'null';
//                                         var isNpc = 1;
//                                         try{
//                                             localStorage.setItem('title',infoList[0].getElementsByClassName('fyg_mp0 fyg_tc')[0].innerText);
//                                             npcTitle = infoList[0].getElementsByClassName('fyg_mp0 fyg_tc')[1].innerText;
//                                         }catch(err){return;}
//                                         switch(npcTitle[npcTitle.length-1]){
//                                             case '人':npcSKL = '三连击';npcName='MU';break;
//                                             case '蛛':npcSKL = '剧毒蛛网';npcName='ZHU';break;
//                                             case '灵':npcSKL = '灵魂爆燃';npcName='DENG';break;
//                                             case '兽':npcSKL = '肉球嘲讽';npcName='SHOU';break;
//                                             default: isNpc = 0; //只统计NPC
//                                         }

//                                         var meProba = {'CRT':0,'SKL':0,'SUM':0};
//                                         var npcProba = {'CRT':0,'SKL':0,'SUM':0};


//                                         if(isNpc){
//                                             switch(localStorage.getItem('cardName')){
//                                                 case '琳':meSKL = '爆裂双刃';meName='LIN';break;
//                                                 case '艾':meSKL = '烈焰宝石';meName='AI';break;
//                                                 case '默':meSKL = '魔力压制';meName='MO';break;
//                                                 case '梦':meSKL = '星轮逆转';meName='MENG';break;
//                                             }
//                                             switch(npcTitle[0]){
//                                                 case '超':npcRate = 3;;break;
//                                                 case '大':npcRate = 2;break;
//                                                 case '强':npcRate = 1;break;
//                                                 default:npcRate = 0;
//                                             }
//                                             npcLv = npcTitle.match(/.?(\d+)./)[1];
//                                             //console.log(npcLv);


//                                             for(let i=2;i<infoList.length-1;i++){
//                                                 var left=infoList[i].children[0].innerText;
//                                                 //console.log(left);
//                                                 var right=infoList[i].children[1].innerText;
//                                                 //console.log(right);
//                                                 if(left.indexOf('暴击')!=-1){
//                                                     meProba.CRT++;
//                                                 }
//                                                 if(right.indexOf('暴击')!=-1){
//                                                     npcProba.CRT++;
//                                                 }
//                                                 if(left.indexOf(meSKL)!=-1){
//                                                     meProba.SKL++;
//                                                 }
//                                                 if(right.indexOf(npcSKL)!=-1){
//                                                     npcProba.SKL++;
//                                                 }
//                                             }
//                                             meProba.SUM = targetNode.firstChild.getElementsByClassName('icon icon-arrow-right text-success').length;
//                                             npcProba.SUM = targetNode.firstChild.getElementsByClassName('icon icon-arrow-left text-success').length
//                                             //[卡片名,智力,敏捷,NPC等级,NPC倍率,我方技能数,我方暴击数,我方攻击数,NPC技能数,NPC暴击数,NPC攻击数]
//                                             var attr = localStorage.getItem('attribute').split(',');
//                                             var probaArray = new Array(npcName,meName,attr[2],attr[1],npcLv,npcRate,
//                                                                        meProba.SKL,meProba.CRT,meProba.SUM,npcProba.SKL,npcProba.CRT,npcProba.SUM);
//                                             localStorage.setItem('over', 0);
//                                             let pk_i = 0;
//                                             while(localStorage.getItem(`pk${pk_i}`)!=null){
//                                                 pk_i++;
//                                             }
//                                             localStorage.setItem(`pk${pk_i}`, probaArray.join(','));
//                                             console.log(`${localStorage.getItem('cardName')}(${localStorage.getItem('attribute')}) vs ${npcTitle}: 该次战斗已保存`);

//                                         }

//                                     }
//                                 };
//                                 // 创建一个observer示例与回调函数相关联
//                                 var observer = new MutationObserver(callback);
//                                 //使用配置文件对目标节点进行观测
//                                 observer.observe(targetNode, config);

//                                 // 停止观测
//                                 //observer.disconnect();
//                             }
//                             else{
//                                 alert(`卡片读取失败,请刷新重试或前往卡片页面手动读取\n当前卡片为:${localStorage.getItem('cardName')}(${localStorage.getItem('attribute')}) 若无误请忽略`);
//                                 btn1.innerHTML = '提交数据';
//                             }
//                         }
//                     })

//                 }
//             })
//         }
//         catch(err){
//             console.log(err);
//             alert(`卡片读取失败,请刷新重试或前往卡片页面手动读取\n当前卡片为:${localStorage.getItem('cardName')}(${localStorage.getItem('attribute')}) 若无误请忽略`);
//             btn1.innerHTML = '提交数据';
//         }
    }
})();