// ==UserScript==
// @name 咕咕镇数据采集
// @namespace https://gf.qytechs.cn/users/448113
// @version 1.0.2
// @description 咕咕镇数据采集,目前采集已关闭,兼作助手
// @author paraii
// @include https://www.guguzhen.com/*
// @grant GM_xmlhttpRequest
// @grant GM_addStyle
// @grant GM_getResourceText
// @resource bootstrapcss <https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css>
// @connect notes.orga.cat
// @connect www.guguzhen.com
// @require https://cdn.jsdelivr.net/npm/[email protected]/dist/jquery.min.js
// @run-at document-idle
// @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'
GM_addStyle(GM_getResourceText('bootstrapcss'));
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].slice(0,-1).join(' ')}`;
text[1].innerText = `${data[1].slice(0,-1).join(' ')}`;
text[2].innerText = `${data[2].slice(0,-1).join(' ')}`;
text[3].innerText = `${data[3].slice(0,-1).join(' ')}`;
let bag = document.getElementById('backpacks').children;
bagdata = getEquipmentInfo(bag);
for(let i =0;i<bagdata.length;i++){
text[5+i].innerText =`${bagdata[i].slice(0,-1).join(' ')}`;
}
}catch(err){console.log(err);}
}
break;
case 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');
div0.setAttribute('id','cardpage_pop');
let initHTML = ` <div class="popup-content">
<div class="topline">
<p></p>
<div class="equipment_selector"></div>
</div>
<div class="topline">
<p></p>
<div class="equipment_selector"></div>
</div>
<div class="topline">
<p></p>
<div class="equipment_selector"></div>
</div>
<div class="topline">
<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;
}
.topline {
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="topline">
<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('topline')[0].children[1].innerText = '装备√';
if(document.getElementsByClassName('topline')[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('topline')[0].children[1].innerText = '装备√';
if(document.getElementsByClassName('topline')[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('topline')[0].children[2].innerText = '光环√';
if(document.getElementsByClassName('topline')[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];
if(p.lastChild.id!='cardpage_pop'){
p.appendChild(div0);
}
}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_beach.php'){
function insertAfter(newEl, targetEl)
{
var parentEl = targetEl.parentNode;
if(parentEl.lastChild == targetEl)
{
parentEl.appendChild(newEl);
}else
{
parentEl.insertBefore(newEl,targetEl.nextSibling);
}
}
let beachCheck = document.createElement('form');
beachCheck.innerHTML = `<div class="form-group form-check">
<label class="form-check-label" for="beachcheck">屏蔽垃圾装备</label>
<input type="checkbox" class="form-check-input" id="beachcheck">
<label>分析中..</label>
</div>`;
document.getElementsByClassName('panel-body')[2].appendChild(beachCheck);
document.querySelector("#beachcheck").addEventListener('click', ()=>{localStorage.setItem('beachcheck',document.querySelector("#beachcheck").checked)}, false);
document.querySelector("#beachcheck").checked = (localStorage.getItem('beachcheck')==='true');
let equipment = new Array();
//读取拥有的装备
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 equipbag = getEquipmentInfo(div0.children);
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 => {
document.querySelector(".form-check").children[2].innerText = '';
let div0 = document.createElement('div');
div0.innerHTML = response.responseText;
let equiped = getEquipmentInfo(div0.getElementsByClassName('fyg_tc')[3].children);
equipment = equipbag.concat(equiped);
if(equipment.length == 0){
equipment[0] = -1;
}
}
});
}
});
//分析装备并显示属性
function pickEquipment(equipment){
if(document.querySelector("#beachcheck").checked){
//屏蔽鼠标事件
$('#beachall .fyg_mp3').css('pointer-events', 'none');
}else{
$('#beachall .fyg_mp3').css('pointer-events', 'auto');
}
if(equipment[0]==-1) return;
let btns = document.getElementsByClassName('fyg_mp3');
for(let i=0;i<btns.length;i++){
if(btns[i].parentNode.id == 'beachall'){
let isFind = false;
let isPick = false;
let btninfo = getEquipmentInfo(new Array(btns[i]))[0];
for(let j=0;j<equipment.length;j++){
if(equipment[j][0]===btninfo[0]){
isFind = true;
let e1 = new Array(parseInt(equipment[j][1]),parseInt(equipment[j][2]),parseInt(equipment[j][3]),parseInt(equipment[j][4]),parseInt(equipment[j][5]));
let e2 = new Array(parseInt(btninfo[1]),parseInt(btninfo[2]),parseInt(btninfo[3]),parseInt(btninfo[4]),parseInt(btninfo[5]));
function product(e1,e2){
return e1*e2;
}
function linear(e1,e2,a,b){
return (e1/a+b)*e2;
}
switch(btninfo[0]){
case 'BLADE':
isPick = (
linear(e1[0],e1[1],5,20)<linear(e2[0],e2[1],5,20)||
linear(e1[0],e1[2],5,20)<linear(e2[0],e2[2],5,20)||
linear(e1[0],e1[3],15,10)<linear(e2[0],e2[3],15,10)||
linear(e1[0],e1[4],12,10)<linear(e2[0],e2[4],12,10));
break;
case 'STAFF':
isPick = (
product(e1[0],e1[1])<product(e2[0],e2[1])||
product(e1[0],e1[2])<product(e2[0],e2[2])||
linear(e1[0],e1[3],12,5)<linear(e2[0],e2[3],12,5)||
linear(e1[0],e1[4],15,10)<linear(e2[0],e2[4],15,10));
break;
case 'SWORD':
isPick = (
product(e1[0],e1[1])<product(e2[0],e2[1])||
product(e1[0],e1[2])<product(e2[0],e2[2])||
product(e1[0],e1[3])<product(e2[0],e2[3])||
linear(e1[0],e1[4],15,10)<linear(e2[0],e2[4],15,10));
break;
case 'BOW':
isPick = product(e1[0],e1[1])<product(e2[0],e2[1])||
product(e1[0],e1[2])<product(e2[0],e2[2])||
product(e1[0],e1[3])<product(e2[0],e2[3])||
linear(e1[0],e1[4],15,10)<linear(e2[0],e2[4],15,10);
break;
case 'GLOVES':
isPick = (
product(e1[0],e1[1])<product(e2[0],e2[1])||
product(e1[0],e1[2])<product(e2[0],e2[2])||
product(e1[0],e1[3])<product(e2[0],e2[3])||
product(e1[0],e1[4])<product(e2[0],e2[4]));
break;
case 'BRACELET':
isPick = (
linear(e1[0],e1[1],5,1)<linear(e2[0],e2[1],5,1)||
linear(e1[0],e1[2],12,1)<linear(e2[0],e2[2],12,1)||
product(e1[0],e1[3])<product(e2[0],e2[3])||
product(e1[0],e1[4])<product(e2[0],e2[4]));
break;
case 'CLOAK':
isPick = (
product(e1[0],e1[1])<product(e2[0],e2[1])||
product(e1[0],e1[2])<product(e2[0],e2[2])||
linear(e1[0],e1[3],3,20)<linear(e2[0],e2[3],3,20)||
product(e1[0],e1[4])<product(e2[0],e2[4]));
break;
case 'CLOTH':
isPick = false;
break;
case 'LEATHER':
isPick = false;
break;
case 'PLATE':
isPick = false;
break;
case 'THORN':
isPick = (
linear(e1[0],e1[1],5,20)<linear(e2[0],e2[1],5,20)||
product(e1[0],e1[2])<product(e2[0],e2[2])||
product(e1[0],e1[3])<product(e2[0],e2[3])||
linear(e1[0],e1[4],15,10)<linear(e2[0],e2[4],15,10));
break;
case 'SCARF':
isPick = (
product(e1[0],e1[1])<product(e2[0],e2[1])||
product(e1[0],e1[2])<product(e2[0],e2[2])||
product(e1[0],e1[3])<product(e2[0],e2[3])||
product(e1[0],e1[4])<product(e2[0],e2[4]));
break;
}
}
}
if(!isFind){
//垃圾甲不捡
switch(btninfo[0]){
case 'CLOTH':
isPick = false;
break;
case 'LEATHER':
isPick = false;
break;
case 'PLATE':
isPick = false;
break;
default:
isPick = true;
}
}
if(isPick){
let btn0 = document.createElement('button');
btn0.setAttribute('class','btn btn-light');
btn0.setAttribute('onclick',btns[i].getAttribute('onclick'));
btn0.innerHTML = `<h3 class="popover-title" style="background-color: ${getComputedStyle(btns[i]).getPropertyValue("background-color")}">${btns[i].dataset.originalTitle}</h3><div class="popover-content">${btns[i].dataset.content}</div>`;
insertAfter(btn0,btns[i]);
}
}
}
}
//等待海滩装备加载
let show = setInterval(()=>{
if($('#beachall .fyg_mp3').toArray().length!=0){
clearInterval(show);
//等待装备读取完成
let pick = setInterval(()=>{
if(equipment.length>0){
clearInterval(pick);
pickEquipment(equipment);
}
},500);
}
},500);
let btnNum = -1;
let getBtnNum = setInterval(()=>{
if($('#beachall .fyg_mp3').toArray().length!=0){
clearInterval(getBtnNum);
btnNum = $('#beachall .fyg_mp3').toArray().length;
}
},2000);
let observerBody0 = new MutationObserver(()=>{
let nowlength = $('#beachall .fyg_mp3').toArray().length;
if(btnNum!=-1 && btnNum!=nowlength){ //海滩装备数量发生改变
btnNum = nowlength;
//等待海滩状态刷新
let readd = setInterval(()=>{
if($('#beachall .btn btn-light').toArray().length==0){
clearInterval(readd);
pickEquipment(equipment);
}
},1000);
}
},1000);
observerBody0.observe(document.getElementsByClassName('panel panel-primary')[2], {childList: true,subtree: true,});
}
else if(window.location.pathname=='/fyg_pk.php'){
let btngroup0 = document.createElement('div');
btngroup0.setAttribute('class','action_selector');
btngroup0.innerHTML = `<p></p><div class="btn-group" role="group">
<button type="button" class="btn btn-secondary">0</button>
<button type="button" class="btn btn-secondary">10</button>
<button type="button" class="btn btn-secondary">20</button>
<button type="button" class="btn btn-secondary">30</button>
<button type="button" class="btn btn-secondary">40</button>
<button type="button" class="btn btn-secondary">50</button>
<button type="button" class="btn btn-secondary">60</button>
<button type="button" class="btn btn-secondary">70</button>
<button type="button" class="btn btn-secondary">80</button>
<button type="button" class="btn btn-secondary">90</button>
<button type="button" class="btn btn-secondary">100</button>
</div>`;
let btngroup1 = document.createElement('div');
btngroup1.setAttribute('class','action_selector');
btngroup1.innerHTML = `<p></p><div class="btn-group" role="group">
<button type="button" class="btn btn-secondary">0</button>
<button type="button" class="btn btn-secondary">5</button>
<button type="button" class="btn btn-secondary">10</button>
<button type="button" class="btn btn-secondary">15</button>
<button type="button" class="btn btn-secondary">20</button>
<button type="button" class="btn btn-secondary">25</button>
<button type="button" class="btn btn-secondary">30</button>
<button type="button" class="btn btn-secondary">35</button>
<button type="button" class="btn btn-secondary">40</button>
<button type="button" class="btn btn-secondary">45</button>
<button type="button" class="btn btn-secondary">50</button>
<button type="button" class="btn btn-secondary">55</button>
<button type="button" class="btn btn-secondary">60</button>
<button type="button" class="btn btn-secondary">65</button>
<button type="button" class="btn btn-secondary">70</button>
<button type="button" class="btn btn-secondary">75</button>
<button type="button" class="btn btn-secondary">80</button>
<button type="button" class="btn btn-secondary">85</button>
<button type="button" class="btn btn-secondary">90</button>
<button type="button" class="btn btn-secondary">95</button>
<button type="button" class="btn btn-secondary">100</button>
</div>`;
let btngroup2 = document.createElement('div');
btngroup2.setAttribute('class','action_selector');
btngroup2.innerHTML = `<p></p><div class="btn-group" role="group">
<button type="button" class="btn btn-secondary">0</button>
<button type="button" class="btn btn-secondary">5</button>
<button type="button" class="btn btn-secondary">10</button>
<button type="button" class="btn btn-secondary">15</button>
<button type="button" class="btn btn-secondary">20</button>
<button type="button" class="btn btn-secondary">25</button>
<button type="button" class="btn btn-secondary">30</button>
<button type="button" class="btn btn-secondary">35</button>
<button type="button" class="btn btn-secondary">40</button>
<button type="button" class="btn btn-secondary">45</button>
<button type="button" class="btn btn-secondary">50</button>
<button type="button" class="btn btn-secondary">55</button>
<button type="button" class="btn btn-secondary">60</button>
<button type="button" class="btn btn-secondary">65</button>
<button type="button" class="btn btn-secondary">70</button>
<button type="button" class="btn btn-secondary">75</button>
<button type="button" class="btn btn-secondary">80</button>
<button type="button" class="btn btn-secondary">85</button>
<button type="button" class="btn btn-secondary">90</button>
<button type="button" class="btn btn-secondary">95</button>
<button type="button" class="btn btn-secondary">100</button>
</div>`;
let observerBody0 = new MutationObserver(()=>{
//observerBody0.disconnect();
if(document.getElementsByClassName('btn-secondary').length==0){
let addbtn = setInterval(()=>{
let col = document.querySelector("#pklist > div > div.col-md-8");
if(col!=null){
clearInterval(addbtn);
let obtns = document.getElementsByClassName('btn-block dropdown-toggle fyg_lh30');
col.insertBefore(btngroup0, obtns[0]);
col.insertBefore(btngroup1, obtns[1]);
col.insertBefore(btngroup2, obtns[2]);
if(document.getElementsByClassName('btn-outline-secondary').length==0){
let ok = document.createElement('div');
ok.innerHTML = `<p></p><button type="button" class="btn btn-outline-secondary">任务执行</button>`;
col.appendChild(ok);
function gobattle(){
let times = new Array(0,0,0);
let sum = 0;
$(".btn-secondary").each(function(i,e){
if($(e).attr("style")!=null&&$(e).css("background-color") == "rgb(135, 206, 250)"){
let a = parseInt(e.innerText);
let b = $(".btn-group .btn-secondary").index(e);
sum+=a;
if(b<11){
times[0] = a/10;
}
else if(b>=11&&b<32){
times[1] = a/5;
}
else if(b>=32){
times[2] = a/5;
}
}
});
if(sum<=parseInt(document.getElementsByClassName('fyg_colpz03')[0].innerText)){
function func0(time) {
if(time==0){
if(times[0]!=0){
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=12',
onload: response => {
let ap = response.responseText.match(/class="fyg_colpz03" style="font-size:32px;font-weight:900;">[0-9]+</)[0].match(/>[0-9]+</)[0].slice(1,-1);
document.getElementsByClassName('fyg_colpz03')[0].innerText = ap;
}
});
times[0] = 0;
}
return;
}
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=16&safeid=edcf1c`,
onload: response => {
if(response.responseText.slice(0,2)=='获得'){
let info = response.responseText.slice(0,response.responseText.indexOf('<'));
let div_info = document.createElement('div');
div_info.innerText = info;
document.getElementsByClassName('btn-outline-secondary')[0].parentNode.appendChild(div_info);
func0(time-1);
}
}
});
}
function func1(time) {
if(time==0) {
times[1] = 0;
return;
}
let observerPk = new MutationObserver((mutationsList, observer) => {
let isPk = 0;
for(let mutation of mutationsList) {
if (mutation.type == 'childList') {
isPk = 1;
//console.log(targetNode.firstChild);
}
}
if(isPk){
observerPk.disconnect();
func1(time-1);
}
});
observerPk.observe(document.querySelector("#pk_text"), {characterData: true,childList: true});
document.getElementsByClassName('btn-block dropdown-toggle fyg_lh30')[1].click();
}
function func2(time) {
if(time==0) {
times[2] = 0;
return;
}
let observerPk = new MutationObserver((mutationsList, observer) => {
let isPk = 0;
for(let mutation of mutationsList) {
if (mutation.type == 'childList') {
isPk = 1;
//console.log(targetNode.firstChild);
}
}
if(isPk){
observerPk.disconnect();
func2(time-1);
}
});
observerPk.observe(document.querySelector("#pk_text"), {characterData: true,childList: true});
document.getElementsByClassName('btn-block dropdown-toggle fyg_lh30')[2].click();
}
func0(times[0]);
let waitFor0 = setInterval(()=>{
if(times[0]==0){
clearInterval(waitFor0);
func1(times[1]);
}
},1000);
let waitFor1 = setInterval(()=>{
if(times[0]==0 && times[1]==0){
clearInterval(waitFor1);
func2(times[2]);
}
},1000);
}
else{
alert('体力不足');
}
}
document.getElementsByClassName('btn-outline-secondary')[0].addEventListener('click', gobattle, false);
}
function selector_act() {
var btnNum = $(".btn-group .btn-secondary").index(this);
$(".btn-group .btn-secondary")
.eq(btnNum)
.css("background-color", "rgb(135, 206, 250)")
.siblings(".btn-group .btn-secondary")
.css("background-color", "rgb(255, 255, 255)");
}
let btnselector = document.getElementsByClassName('btn-secondary');
for(let i=0;i<btnselector.length;i++){
btnselector[i].addEventListener('click', selector_act, false);
}
}
}, 1000);
}
});
observerBody0.observe(document.getElementsByClassName('panel panel-primary')[0], {childList: true,subtree: true,});
let keepCheck = document.createElement('form');
keepCheck.innerHTML = `<div class="form-group form-check">
<label class="form-check-label" for="keepcheck">暂时保持记录</label>
<input type="checkbox" class="form-check-input" id="keepcheck">
</div>`;
document.getElementsByClassName('panel panel-primary')[1].insertBefore(keepCheck,document.getElementById('pk_text'));
document.querySelector("#keepcheck").addEventListener('click', ()=>{localStorage.setItem('keepcheck',document.querySelector("#keepcheck").checked)}, false);
document.querySelector("#keepcheck").checked = (localStorage.getItem('keepcheck')==='true');
let div0_pk_text_more = document.createElement('div');
div0_pk_text_more.setAttribute('id','pk_text_more');
div0_pk_text_more.setAttribute('class','panel-body');
document.getElementsByClassName('panel panel-primary')[1].appendChild(div0_pk_text_more);
let pkText = document.querySelector("#pk_text").innerHTML;
let observerBody1 = new MutationObserver(()=>{
console.log(1);
if(document.querySelector("#keepcheck").checked==true){
document.querySelector("#pk_text_more").innerHTML = pkText + document.querySelector("#pk_text_more").innerHTML;
pkText = document.querySelector("#pk_text").innerHTML
}
});
observerBody1.observe(document.querySelector("#pk_text"), {characterData: true,childList: true});
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 = '提交数据';
// }
}
})();