您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
咕咕镇数据采集,目前采集技能率、暴击率
当前为
// ==UserScript== // @name 咕咕镇数据采集 // @namespace https://greasyfork.org/users/448113 // @version 0.2.3 // @description 咕咕镇数据采集,目前采集技能率、暴击率 // @author paraii // @include https://www.lv999max.com/* // @grant GM_xmlhttpRequest // @connect notes.orga.cat // @connect www.lv999max.com // @license MIT License // ==/UserScript== function submitData(){ var 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(localStorage.length>2&&localStorage.getItem('over')=='1'){ var meURL = `https://notes.orga.cat/${encodeURI(localStorage.getItem('title')).replace(/%/g, '')}`; console.log(meURL); GM_xmlhttpRequest({ method: 'GET', url: meURL, timeout: 30000, headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}, onload: response => { var 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,'"'); } var json = JSON.parse(text); for(let i = 0; i < localStorage.length-2; i++){ var a = localStorage.getItem(`pk${i}`).split(','); var 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); } } 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 => { localStorage.clear(); alert('数据已提交'); return 1; } }) } }) }else{ return 0; } } (function() { 'use strict' if(window.location.pathname=='/fyg_pk.php'){ var btn =document.createElement("button"); btn.innerHTML = '正在读取卡片...'; btn.onclick = ()=>{ try{ if(submitData()){ return; } } catch(err){ alert('数据提交失败,请刷新重试'); } }; var p = document.getElementsByClassName('panel panel-primary')[0]; p.insertBefore(btn,p.children[0]); var attribute = new Array(); var meName = 'null'; var meSKL = 'null'; 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]; meName = n.substr(1,n.length-2); }catch(err){} 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); response.responseText.match(/>(\d+)</g).forEach(item => { attribute.push(item.substr(1,item.length-2)); }); attribute.shift(); console.log(meName); console.log(attribute); if(meName!='0'&&attribute.length!=0){ //alert('卡片读取完成'); btn.innerHTML = '提交数据'; switch(meName){ case '琳':meSKL = '爆裂双刃';meName='LIN';break; case '艾':meSKL = '烈焰宝石';meName='AI';break; case '默':meSKL = '魔力压制';meName='MO';break; case '梦':meSKL = '星轮逆转';meName='MENG';break; } 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 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(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 probaArray = new Array(npcName,meName,attribute[2],attribute[1],npcLv,npcRate, meProba.SKL,meProba.CRT,meProba.SUM,npcProba.SKL,npcProba.CRT,npcProba.SUM); localStorage.setItem('over', 0); localStorage.setItem(`pk${localStorage.length-2}`, probaArray.join(',')); console.log(`${npcTitle}: 该次战斗已保存`); } } }; // 创建一个observer示例与回调函数相关联 var observer = new MutationObserver(callback); //使用配置文件对目标节点进行观测 observer.observe(targetNode, config); // 停止观测 //observer.disconnect(); } else{ alert('卡片读取失败,请刷新重试'); } } }) } }) } catch(err){ alert('卡片读取失败,请刷新重试'); } } })();