您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
咕咕镇数据采集,目前采集技能率、暴击率(采集已关闭)
当前为
// ==UserScript== // @name 咕咕镇数据采集(兼助手) // @namespace https://greasyfork.org/users/448113 // @version 0.5.2 // @description 咕咕镇数据采集,目前采集技能率、暴击率(采集已关闭) // @author paraii // @include https://www.guguzhen.com/* // @grant GM_xmlhttpRequest // @connect notes.orga.cat // @connect www.guguzhen.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(/"/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 getEquipmentInfo(nodes){ let data = new Array(); if(nodes.length>0){ for(let i=0;i<nodes.length;i++){ let atrr = nodes[i].getAttribute('data-content').match(/>[0-9]+%</g); let title = 0; title = nodes[i].getAttribute('data-original-title'); if(title==null){ title = nodes[i].getAttribute('title'); } let lv = title.match(/>[0-9]+</g)[0]; let name = title.substr(title.lastIndexOf('>')+1); let mys = 0; let id = nodes[i].getAttribute('onclick'); if(id!=null){ id = id.match(/([0-9]+)/)[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,id)); } } return data; } (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: $('.pop_main').hide(); 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]; data = getEquipmentInfo(equip.children); 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; bagdata = getEquipmentInfo(bag); 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); $('.pop_main').hide(); btnc1.onclick = ()=>{}; try{ let cards = document.getElementsByClassName('dropdown-menu'); for(let i=0;i<cards.length;i++) { let li0 = document.createElement('li'); li0.setAttribute('class','fyg_lh30'); li0.innerHTML = '<a href="###" style="color:#F00" onclick="showPopup(this)"> 绑定装备&光环 </a>' let li1 = document.createElement('li'); li1.setAttribute('class','fyg_lh30'); li1.innerHTML = '<a href="###" style="color:#00FF" onclick="equipOnekey(this)"> 一键装备 </a>' cards[i].appendChild(li0);cards[i].appendChild(li1); } let div0 = document.createElement('div'); let initHTML = ` <div class="popup-content"> <div class="top"> <p></p> <div class="equipment_selector"></div> </div> <div class="top"> <p></p> <div class="equipment_selector"></div> </div> <div class="top"> <p></p> <div class="equipment_selector"></div> </div> <div class="top"> <p></p> <div class="equipment_selector"></div> </div> <p></p> <div class="halo_selector"></div> <p id="load_tip">读取中...</p> <button type="button" id="bind">绑定</button> <button type="button" onclick="unbind()">解除绑定</button> <button type="button" onclick="quit()">取消</button> </div>`; div0.innerHTML =` <style> .popup { width: 100vw; height: 100vh; background-color: rgba(0, 0, 0, .5); position: fixed; left: 0; top: 0; bottom: 0; right: 0; z-index: 9999; display: none; justify-content: center; align-items: center; } .popup-content { width: 400px; height: 200px; background-color: #fff; box-sizing: border-box; padding: 10px 30px; color: black; } .top { width: 100%; border-bottom: 1px solid black; } </style> <div class="popup" id="popup"> ${initHTML} </div>`; unsafeWindow.equipOnekey = function(t) { $('.popup-content').height(100); $('.popup-content').width(100); document.getElementById("popup").innerHTML = `<div class="popup-content"> <div class="top"> <p></p> <div>装备×</div> <div>光环×</div> </div> <div>更换中..</div> <button type="button" onclick="quit()">取消</button> </div>`; let role = t.parentNode.parentNode.parentNode.children[0].innerText.replace(/\n/g,''); let roleId = t.parentNode.parentNode.children[1].children[0].getAttribute('onclick').match(/([0-9]+)/)[0]; let bind_info = localStorage.getItem(`${role}`); if(bind_info!=null){ GM_xmlhttpRequest({ method: 'POST', url: `https://www.guguzhen.com/fyg_click.php`, headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}, data: `c=5&id=${roleId}&safeid=edcf1c`, onload: response => { if(response.responseText=='ok'){ bind_info = bind_info.split('|'); let equRequest = GM_xmlhttpRequest({ method: 'POST', url: `https://www.guguzhen.com/fyg_read.php`, headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}, data: 'f=7', onload: response => { let div0 = document.createElement('div'); div0.innerHTML = response.responseText; let equipment = getEquipmentInfo(div0.children); let equiped = getEquipmentInfo(document.getElementsByClassName('fyg_tc')[3].children); let ids = new Array(); let err = 0; for(let i=0;i<4;i++){ let exist = 0; for(let j=0;j<4;j++){ if(bind_info[i]===equiped[j].slice(0,-2).join()){ exist = 1; break; } } if(exist==0){ for(let j=0;j<equipment.length;j++){ if(bind_info[i]===equipment[j].slice(0,-2).join()){ ids.push(equipment[j][equipment[j].length-1]); exist = 1; break; } } if(exist==0){ alert('有装备不存在,请重新绑定'); err = 1; window.location.reload(); } } } if(err==0){ let c = ids.length; if(c==0){ document.getElementsByClassName('top')[0].children[1].innerText = '装备√'; if(document.getElementsByClassName('top')[0].children[2].innerText == '光环√'){ window.location.reload(); document.getElementById("popup").style.display = "none"; } } for(let i=0;i<ids.length;i++){ GM_xmlhttpRequest({ method: 'POST', url: `https://www.guguzhen.com/fyg_click.php`, headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}, data: `c=3&id=${ids[i]}&safeid=edcf1c`, onload: response => { if(response.responseText=='ok'){ c--; if(c==0){ document.getElementsByClassName('top')[0].children[1].innerText = '装备√'; if(document.getElementsByClassName('top')[0].children[2].innerText == '光环√'){ window.location.reload(); document.getElementById("popup").style.display = "none"; } } } } }); } } } }); let halo = bind_info[bind_info.length-1].split(','); for(let i=0;i<halo.length;i++){ switch(halo[i]){ case '启程之誓': halo[i] = '101'; break; case '启程之心': halo[i] = '102'; break; case '启程之风': halo[i] = '103'; break; case '破壁之心': halo[i] = '201'; break; case '破魔之心': halo[i] = '202'; break; case '伤口恶化': halo[i] = '301'; break; case '精神创伤': halo[i] = '302'; break; case '铁甲尖刺': halo[i] = '303'; break; case '沸血之志': halo[i] = '401'; break; case '波澜不惊': halo[i] = '402'; break; case '飓风之力': halo[i] = '403'; break; } } let haloRequest = GM_xmlhttpRequest({ method: 'POST', url: `https://www.guguzhen.com/fyg_click.php`, headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}, data: `c=4&arr=${halo.join()}&safeid=edcf1c`, onload: response => { if(response.responseText=='ok'){ document.getElementsByClassName('top')[0].children[2].innerText = '光环√'; if(document.getElementsByClassName('top')[0].children[1].innerText == '装备√'){ window.location.reload(); document.getElementById("popup").style.display = "none"; } } } }); unsafeWindow.quit = function() { document.getElementById("popup").style.display = "none"; equRequest.abort(); haloRequest.abort(); document.getElementById("popup").innerHTML = initHTML; }; document.getElementById("popup").style.display = "flex"; } } }); } else{ alert('未绑定'); } } unsafeWindow.showPopup = function(t) { document.getElementById("popup").innerHTML = initHTML; let role = t.parentNode.parentNode.parentNode.children[0].innerText.replace(/\n/g,''); let equRequest = GM_xmlhttpRequest({ method: 'POST', url: `https://www.guguzhen.com/fyg_read.php`, headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}, data: 'f=7', onload: response => { let div0 = document.createElement('div'); div0.innerHTML = response.responseText; let equipment = getEquipmentInfo(div0.children); equipment = equipment.concat(getEquipmentInfo(document.getElementsByClassName('fyg_tc')[3].children)); $('.popup-content').height(equipment.length*30+150); $('.popup-content').width(400); let BLADE = new Array(); let STAFF = new Array(); let SWORD = new Array(); let BOW = new Array(); let GLOVES = new Array(); let BRACELET = new Array(); let CLOAK = new Array(); let CLOTH = new Array(); let LEATHER = new Array(); let PLATE = new Array(); let THORN = new Array(); let SCARF = new Array(); equipment.forEach(item=>{ switch(item[0]){ case 'BLADE': BLADE.push(new Array('刃',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; case 'STAFF': STAFF.push(new Array('杖',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; case 'SWORD': SWORD.push(new Array('剑',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; case 'BOW': BOW.push(new Array('弓',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; case 'GLOVES': GLOVES.push(new Array('手套',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; case 'BRACELET': BRACELET.push(new Array('手环',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; case 'CLOAK': CLOAK.push(new Array('灵光袍',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; case 'CLOTH': CLOTH.push(new Array('布甲',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; case 'LEATHER': LEATHER.push(new Array('皮甲',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; case 'PLATE': PLATE.push(new Array('铁甲',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; case 'THORN': THORN.push(new Array('重甲',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; case 'SCARF': SCARF.push(new Array('头巾',`Lv${item[1]}`,`${item[2]}%`,`${item[3]}%`,`${item[4]}%`,`${item[5]}%`)); break; } }); function selector_equ() { var equipNum = $(".equipment_selector .equipment_item").index(this); $(".equipment_selector .equipment_item") .eq(equipNum) .css("background-color", "rgb(135, 206, 250)") .siblings(".equipment_selector .equipment_item") .css("background-color", "rgb(255, 255, 255)"); } let content = document.getElementsByClassName('equipment_selector'); let e = new Array().concat(new Array(BLADE.concat(STAFF,SWORD,BOW)),new Array(GLOVES.concat(BRACELET)),new Array(CLOAK.concat(CLOTH,LEATHER,PLATE,THORN)),new Array(SCARF)); for(let i=0;i<4;i++){ for(let j=0;j<e[i].length;j++){ let li0 = document.createElement('li'); li0.setAttribute('class','equipment_item'); li0.addEventListener('click', selector_equ, false); li0.innerHTML = `<a href="javascript:void(0)">${e[i][j].join(' ')}</a>`; content[i].appendChild(li0); } } } }); localStorage.setItem('halo_max','0'); let haloRequest = GM_xmlhttpRequest({ method: 'POST', url: `https://www.guguzhen.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(/<h3>.*</)[0].slice(4,-1); localStorage.setItem('halo_max',halo.match(/[0-9]+/).join()); halo = `天赋点:${halo.match(/[0-9]+/)[0]},技能位:${role.match(/[0-9]技/)[0].slice(0,1)}`; document.getElementsByClassName('halo_selector')[0].innerHTML = `<div>${halo}</div> <a href="javascript:void(0)" class="halo_item">启程之誓 10</a> <a href="javascript:void(0)" class="halo_item">启程之心 10</a> <a href="javascript:void(0)" class="halo_item">启程之风 10</a> <div></div> <a href="javascript:void(0)" class="halo_item">破壁之心 30</a> <a href="javascript:void(0)" class="halo_item">破魔之心 30</a> <div></div> <a href="javascript:void(0)" class="halo_item">伤口恶化 50</a> <a href="javascript:void(0)" class="halo_item">精神创伤 50</a> <a href="javascript:void(0)" class="halo_item">铁甲尖刺 50</a> <div></div> <a href="javascript:void(0)" class="halo_item">沸血之志 100</a> <a href="javascript:void(0)" class="halo_item">波澜不惊 100</a> <a href="javascript:void(0)" class="halo_item">飓风之力 100</a>`; function selector_halo() { if($(this).css('background-color')!='rgb(135, 206, 250)'){ $(this).css('background-color','rgb(135, 206, 250)'); } else{ $(this).css('background-color','rgb(255, 255, 255)'); } } $('.halo_item').each(function(i,e){ $(e).on('click', selector_halo); }); document.getElementById('load_tip').innerText = ''; } }); unsafeWindow.quit = function() { document.getElementById("popup").style.display = "none"; equRequest.abort(); haloRequest.abort(); document.getElementById("popup").innerHTML = initHTML; }; unsafeWindow.unbind = function() { if(localStorage.getItem(`${role}`)!=null){ localStorage.removeItem(`${role}`); } }; function hidePopup() { let equ = new Array(); let halo = new Array(); let sum = 0; $(".equipment_item").each(function(i,e){ if($(e).attr("style")!=null&&$(e).css("background-color") != "rgb(255, 255, 255)"){ equ.push(e.innerText.split(' ')); } }); $(".halo_item").each(function(i,e){ if($(e).attr("style")!=null&&$(e).css("background-color") != "rgb(255, 255, 255)"){ let ee = e.innerText.split(' '); sum+=parseInt(ee[1]); halo.push(ee[0]); } }); let h = parseInt(localStorage.getItem('halo_max')); if(equ.length==4&&sum<h&&halo.length<=parseInt(role.match(/[0-9]技/).slice(0,1))){ for(let i=0;i<4;i++){ let name = equ[i][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; } } equ[i][0] = name; equ[i][1] = equ[i][1].substr(2); for(let j=2;j<6;j++){ equ[i][j] = equ[i][j].slice(0, -1) } } let bind_info = new Array(equ[0],equ[1],equ[2],equ[3],halo); localStorage.setItem(role,bind_info.join('|')); console.log(localStorage); document.getElementById("popup").innerHTML = initHTML; document.getElementById("popup").style.display = "none"; } else{ alert('有装备未选或天赋错误'); } } document.getElementById('bind').addEventListener('click', hidePopup, false); document.getElementById("popup").style.display = "flex"; }; let p = document.getElementsByClassName('panel panel-primary')[1]; p.insertBefore(div0,p.children[0]); }catch(err){console.log(err);} break; case 2: $('.pop_main').hide(); 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: $('.pop_main').hide(); 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.guguzhen.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.guguzhen.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.guguzhen.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 = '提交数据'; // } } })();