您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
斗争者的小助手
当前为
// ==UserScript== // @name 咕咕镇剩余价值收割机 // @namespace https://greasyfork.org/zh-CN/users/453092 // @version 2.46 // @description 斗争者的小助手 // @author ikarosf // @match https://www.guguzhen.com/fyg_pk.php // @match https://www.guguzhen.com/fyg_shop.php // @require https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.min.js // @require https://greasyfork.org/scripts/411259-%E5%BC%B9%E5%87%BA%E6%97%A5%E5%8E%86%E9%80%89%E6%8B%A9%E6%97%A5%E6%9C%9F%E6%8F%92%E4%BB%B6/code/%E5%BC%B9%E5%87%BA%E6%97%A5%E5%8E%86%E9%80%89%E6%8B%A9%E6%97%A5%E6%9C%9F%E6%8F%92%E4%BB%B6.js // @resource dateTimecss https://greasyfork.org/zh-CN/scripts/411258-%E5%BC%B9%E5%87%BA%E6%97%A5%E5%8E%86%E9%80%89%E6%8B%A9%E6%97%A5%E6%9C%9F%E6%8F%92%E4%BB%B6%E7%9A%84css/code // @connect bbs.fygal.com // @connect kf.miaola.info // @connect bbs.kforz.com // @connect bbs.bakabbs.com // @connect bbs.365gal.com // @connect bbs.365galgame.com // @connect bbs.kfmax.com // @grant GM_getResourceText // @grant GM_xmlhttpRequest // @grant unsafeWindow // @grant GM_setValue // @grant GM_getValue // @grant GM_addStyle // @require https://greasyfork.org/scripts/409864-url-gbk-%E7%BC%96%E7%A0%81%E8%A7%A3%E7%A0%81%E5%BA%93/code/URL%20GBK%20%E7%BC%96%E7%A0%81%E8%A7%A3%E7%A0%81%E5%BA%93.js?version=840815 // ==/UserScript== function fyg_pk_html() { 'use strict'; var debugmode = false; var ctx = document.createElement("battleCountChart"); var goxpanel= document.createElement('div'); var goxpanelExtend= document.createElement('div'); var goxpanelbottom= document.createElement('div'); var detaillogpanel = document.createElement('div'); var mask = document.createElement('div'); var BattleLog = {} if(FM_getValue("BattleLog")!=null){ console.log("BattleLog load") BattleLog = FM_getValue("BattleLog"); } unsafeWindow.BattleLog = BattleLog; if(localStorage.getItem('dataReward')==null){ localStorage.setItem('dataReward','{"sumShell":"0","sumExp":"0"}'); } var goxing = false; var mainHost = "https://bbs.kfmax.com/" if(localStorage.getItem('mainHost')!==null){ mainHost = localStorage.getItem('mainHost'); } var autogox=false; var maxap=999; var maxrank=999; if(localStorage.getItem('maxap')!==null){ maxap = parseInt(localStorage.getItem('maxap')); } if(localStorage.getItem('maxrank')!==null){ maxrank = parseInt(localStorage.getItem('maxrank')); } var autoreStaminaing = false; /* var autoreStamina = false; var autoreStaminaNum = 0; if(FM_getValue('autoreStamina')!==null){ autoreStamina = FM_getValue('autoreStamina'); } if(FM_getValue('autoreStaminaNum')!==null){ autoreStaminaNum = FM_getValue('autoreStaminaNum'); }*/ //var audio = new Audio("https://cdnringhlt.shoujiduoduo.com/ringres/user/a24/564/9246564.aac"); //audio.load(); var Num = 0; var goxNum = 0; var beike=0; var jingyan=0; if(localStorage.getItem('flashtime')===null){ localStorage.setItem('flashtime',10 ); } var maxtime = 10; maxtime = parseInt(localStorage.getItem('flashtime')); var time = maxtime; var myrank = -100; var myap=-100; var changeLog = []; let autoconfig = document.createElement('div'); let autoconfigranklabel = document.createElement('i'); autoconfigranklabel.innerText = "进度不低于:"; autoconfig.appendChild(autoconfigranklabel); let autoconfigrank = document.createElement('input'); autoconfigrank.setAttribute('type','text'); autoconfigrank.setAttribute('oninput',"value=value.replace(/[^\\d]/g,'')"); autoconfigrank.setAttribute('style',"width: 40px;margin-right:15px;"); autoconfigrank.value = maxrank; autoconfigrank.onchange = function(){ maxrank = autoconfigrank.value; autoconfigcheckbox.checked = false; localStorage.setItem('maxrank',maxrank ); }; autoconfig.appendChild(autoconfigrank); let autoconfigaplabel = document.createElement('i'); autoconfigaplabel.innerText = "体力不低于:"; autoconfig.appendChild(autoconfigaplabel); let autoconfigap = document.createElement('input'); autoconfigap.setAttribute('type','text'); autoconfigap.setAttribute('oninput',"value=value.replace(/[^\\d]/g,'')"); autoconfigap.setAttribute('style',"width: 40px;margin-right:15px;"); autoconfigap.value=maxap; autoconfigap.onchange = function(){ maxap = autoconfigap.value; autoconfigcheckbox.checked = false; localStorage.setItem('maxap',maxap ); }; autoconfig.appendChild(autoconfigap); var autoconfigcheckboxdiv= document.createElement('div'); let autoconfigcheckbox = document.createElement('input'); autoconfigcheckbox.setAttribute('type','checkbox'); autoconfigcheckboxdiv.appendChild(autoconfigcheckbox); let autoconfigcheckboxtext = document.createElement('i'); autoconfigcheckboxtext.innerText = "自动搜刮"; autoconfigcheckboxtext.setAttribute('style',"margin-right:20px;"); autoconfigcheckboxtext.setAttribute('class',"smalldiv"); autoconfigcheckboxdiv.appendChild(autoconfigcheckboxtext); let br = document.createElement('br'); autoconfig.appendChild(br); let autoreStaminacheckbox = document.createElement('input'); autoreStaminacheckbox.setAttribute('type','checkbox'); autoconfig.appendChild(autoreStaminacheckbox); let autoreStaminacheckboxtext = document.createElement('i'); autoreStaminacheckboxtext.innerText = "自动消耗星沙回体"; autoreStaminacheckboxtext.setAttribute('style',"margin-right:20px;"); autoreStaminacheckboxtext.setAttribute('class',"smalldiv"); autoconfig.appendChild(autoreStaminacheckboxtext); /*let autoreStaminaaplabel = document.createElement('i'); autoreStaminaaplabel.innerText = "自动回体次数:"; autoconfig.appendChild(autoreStaminaaplabel); let autoreStaminaap = document.createElement('input'); autoreStaminaap.setAttribute('type','text'); autoreStaminaap.setAttribute('oninput',"value=value.replace(/[^\\d]/g,'')"); autoreStaminaap.setAttribute('style',"width: 40px;margin-right:15px;"); autoreStaminaap.value=autoreStaminaNum; autoreStaminaap.onchange = function(){ autoreStaminaNum = autoreStaminaap.value; //autoreStaminacheckbox.checked = false; FM_setValue('autoreStaminaNum',autoreStaminaNum ); }; autoconfig.appendChild(autoreStaminaap); */ function setflashtime(){ var newtime = parseInt(prompt("新的刷新间隔:(填0则禁止刷新)",maxtime)); if(!isNaN(newtime)&&newtime>0){ localStorage.setItem('flashtime',newtime ); maxtime = newtime; time = newtime; return; } if(!isNaN(newtime)&&newtime<=0){ localStorage.setItem('flashtime',newtime ); maxtime = -1; } } function setmainHost(){ var newmainHost = prompt("格式如https://bbs.kfmax.com/(填0则不获取对手系数)",mainHost); if(newmainHost!=null&&newmainHost!=""){ localStorage.setItem('mainHost',newmainHost ); mainHost = newmainHost; } show_battle_log("主站域名:"+mainHost) } //document.getElementsByClassName('panel panel-primary')[1].appendChild(autoconfig); let progresschange = document.createElement('div'); progresschange.setAttribute('id','progresschange'); progresschange.setAttribute('class','panel-body'); //document.getElementsByClassName('panel panel-primary')[1].appendChild(progresschange); function getNowtime(){ var date=getLocDate(); var datetext = date.getHours()+":"+date.getMinutes()+":"+date.getSeconds(); return datetext; } function dlog(text){ if(debugmode){console.log(text)} } function getPostData(p1,p2){ let data = -1; for(let s of document.getElementsByTagName('script')){ let func = s.innerText.match(p1) if(func!=null){ data = func[0].match(p2)[0]; break; } } return data } function postRequest(){ 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 => { Num++; let newrank = parseInt(response.responseText.match(/class="fyg_colpz02" style="font-size:32px;font-weight:900;">[0-9]+%</)[0].match(/[0-9]+%/)[0]); let newap = parseInt(response.responseText.match(/class="fyg_colpz03" style="font-size:32px;font-weight:900;">[0-9]+</)[0].match(/>[0-9]+</)[0].slice(1,-1)); if(myrank == -100){ myrank = newrank; } else if(newrank != myrank){ document.getElementsByClassName('fyg_colpz02')[0].innerText = newrank + "%"; changeLog.push(getNowtime()+" "+myrank+"%->"+newrank + "%") myrank = newrank; //audio.play(); /*var my_url = location.href; var newwin = window.open(my_url, '进度变动', 'resizable=no')*/ } if(myap == -100){ myap = newap; } else if(newap != myap){ document.getElementsByClassName('fyg_colpz03')[0].innerText = newap; myap = newap; } if(autoconfigcheckbox.checked&&newap>=10&&newrank>=1&&newap>=maxap&&newrank>=maxrank&&goxing==false){ maxtime = 1; time = 1; goxNum++; let gox_data = getPostData(/gox\(\)\{[\s\S]*\}/m,/data: ".*"/).slice(7,-1); goxing = true; GM_xmlhttpRequest({ method: 'POST', url: `https://www.guguzhen.com/fyg_click.php`, headers: {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}, data: gox_data, onload: response => { goxing = false; if(response.status === 200){ console.log(response.responseText); 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; changeLog.push(getNowtime() + " " + info) let dataReward = JSON.parse(localStorage.getItem('dataReward')); if(info.indexOf('贝壳')!=-1){ beike++; dataReward.sumShell++; } else if(info.indexOf('经验')!=-1){ jingyan++; dataReward.sumExp++; } localStorage.setItem('dataReward',JSON.stringify(dataReward)); document.getElementsByClassName('btn-outline-secondary')[0].parentNode.appendChild(div_info); } else{ let div_info = document.createElement('div'); div_info.innerText = '段位进度不足'; changeLog.push(getNowtime() + " " + '段位进度不足,搜刮失败') document.getElementsByClassName('btn-outline-secondary')[0].parentNode.appendChild(div_info); } } else{ console.log('返回状态码非200') changeLog.push(getNowtime() + " " + '返回状态码非200') console.log(response.responseText); } }, onerror : function(err){ goxing = false; console.log('发送搜刮请求出错') changeLog.push(getNowtime() + " " + '发送搜刮请求出错') console.log(err) }, ontimeout : function(){ goxing = false; } }); }else if(autoconfigcheckbox.checked&&autoreStaminacheckbox.checked&&!autoreStaminaing&&newrank>=1&&newap>=maxap&&newrank>=maxrank&&goxing==false){ unsafeWindow.gx_sxds() maxtime = 1; time = 1; }else{ maxtime = parseInt(localStorage.getItem('flashtime')); time = maxtime; //console.log(123) } progresschange.innerText = getChangeLogText(); /* else{ document.getElementsByClassName('fyg_colpz02')[0].innerText = newrank; }*/ } }); } function read_rank(){ if(maxtime == -1){ $("#goxtiptext").text("无刷新"); return; } if(--time!=0){ $("#goxtiptext").text("刷新进度倒计时 "+time); }else{ $("#goxtiptext").text("刷新进度倒计时 "+0); time = maxtime; postRequest(); } } function getChangeLogText(){ let LogText = ""; LogText += "刷新次数: " +Num + "\n"; LogText += "[搜刮次数: " +goxNum +"] [贝壳:"+beike+"] [经验:"+jingyan+ "]\n"; if(changeLog.length == 0){ LogText += "未出现进度变动" } else{ for(var i = 0;i<changeLog.length;i++){ LogText += changeLog[i] + "\n" } } return LogText; } postRequest(); setInterval(read_rank,"1000"); var get_user_theard_try_num = 0; function show_battle_log(text){ $("#goxtipbottomtext").text(text); } function get_user_theard(name,enemydiv){ var search_name = $URL.encode(name); dlog(mainHost+'search.php'+name) show_battle_log('搜素帖子中') GM_xmlhttpRequest({ method: "post", url: mainHost+'search.php', data: 'step=2&method=AND&sch_area=0&s_type=forum&f_fid=all&orderway=lastpost&asc=DESC&keyword=&pwuser='+search_name, headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, onload: function(res){ if(res.status === 200){ let info = res.responseText; let firstindex = info.indexOf("共搜索到"); if(firstindex == -1){ if( info.indexOf("用户不存在")!=-1){ show_battle_log('用户'+name+'不存在'); get_user_theard_try_num = 0; return; } if( info.indexOf("你所属的用户组不能使用搜索功能")!=-1){ show_battle_log('主站域名错误或无权限'); get_user_theard_try_num = 0; return; } console.log('搜索尝试次数:' + get_user_theard_try_num) if(info.indexOf("搜索排队中")!=-1&&get_user_theard_try_num<3){ get_user_theard_try_num++; setTimeout(get_user_theard,2000,name,enemydiv) }else{ //console.log(info) get_user_theard_try_num = 0; show_battle_log('找不到'+name+'的帖子,可能他未发过主题帖') } return; } let secondindex = info.indexOf("共搜索到",firstindex+1); info = info.substring(firstindex,secondindex) var theards=info.match(/read\.php.+?(?=" )/g) get_user_mainpage(theards,enemydiv,name); }else{ show_battle_log('搜索对手帖子失败') console.log(res) } }, onerror : function(err){ show_battle_log('搜索对手帖子错误,可能域名设置格式不正确') console.log(err) } }); } function get_user_mainpage(theards,enemydiv,name){ if(theards==null||theards.length<1){ show_battle_log('找不到'+name+'的帖子') return} show_battle_log('进入帖子中') var theard = theards[0]; dlog(mainHost+theard) GM_xmlhttpRequest({ method: "get", url: mainHost+theard , headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, onload: function(res){ if(res.status === 200){ let info = res.responseText; let firstindex = info.indexOf("楼主"); let afterinfo = info.substring(0,firstindex) var mainpage=afterinfo.match(/profile\.php\?action=show.+?(?=" )/g) if(mainpage==null||mainpage.length==0){ afterinfo = info.substring(0,firstindex+100) mainpage=afterinfo.match(/\/user\/uid.+(?=" )/g) get_user_LV(mainpage,enemydiv,name); }else{ get_user_LV(mainpage,enemydiv,name);} }else{ show_battle_log('获取'+name+'主页失败') console.log(res) } }, onerror : function(err){ show_battle_log('获取'+name+'主页错误') console.log(err) } }); } function get_user_LV(mainpages,enemydiv,name){ dlog(mainHost+mainpages[0]) show_battle_log('进入主页中') if(mainpages==null||mainpages.length<1){ show_battle_log('找不到'+name+'的主页') return;} var mainpage = mainpages[0]; if(mainpage.indexOf("uid=null")!=-1){ show_battle_log(name+'已被封禁') return; } GM_xmlhttpRequest({ method: "get", url: mainHost+mainpage , headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' }, onload: function(res){ if(res.status === 200){ let info = res.responseText; dlog(info) let afterinfo = info.replace(/\<\/strong\>/g,''); dlog(afterinfo) var level = afterinfo.match(/(?<=神秘系数:)\d+/g)[0] save_enemylevel(name,level);//存储对手系数 enemydiv.innerHTML = enemydiv.innerHTML.replace(enemydiv.innerText, '<a target="_blank" href='+mainHost+mainpage+'>'+enemydiv.innerText + " Lv:" + level+ '</a>') show_battle_log("获取"+name+"系数成功") }else{ show_battle_log('进入'+name+'主页失败') console.log(res) } }, onerror : function(err){ show_battle_log('进入'+name+'主页错误') console.log(err) } }); } var mycssinner = function () { /* #chartParent{ width:1200px; height:80%; position:fixed; margin:auto; left:0; right:0; top:0; bottom:0; display:none; z-index:10; } .tc_xs{ overflow-x:hidden; width:1200px; height:80%; //line-height:3rem; background:#fff; position:fixed; margin:auto; left:0; right:0; top:0; bottom:0; color:#fff; border-radius:4px; display:none; z-index:10; } #mask{ display:none; width:100%; height:300%; position:absolute; top:0; left:0; z-index:2; background-color:#000; opacity:0.3; } #goxpanel{ width:20%; height:60%; min-width:280px; line-height:3rem; background:#ddf3f5; position:fixed; //left:10%; //margin-left:-15%; top:15%; text-align:center; color:#fff; border-radius:4px; } #goxpanelExtend{ width:20%; height:5%; min-width:280px; line-height:3rem; background:#ddf3f5; position:fixed; //left:10%; //margin-left:-15%; top:75%; text-align:center; color:#000; border-radius:4px; display:none; } .goxtip{ width:100%; background-color: #3280fc; padding: 2px 10px; text-align: left; display: flex; justify-content: space-between; } .goxtip button,input,select,textarea { font-family: inherit; font-size: inherit; line-height:normal; } .goxtipbottom{ position:absolute; bottom:10px; } #goxtipinfo{ color:#000; text-align: left; height: 90%; } .btn-details{ width:30% } #goxpanel a{ color:#FFF; } .battlelose>.nameandlevel { background-color: #ffe5e0 !important; } .nameandlevel{ cursor:pointer; height:30px; margin:auto; color: #03a2b6; text-align: center; background-color:#ddf3f5; } .nameandlevel>h3{ margin-top:5px; line-height: 200%; } #smallbar { position: absolute; right: 0px; height: 100%; width: 10px; text-align: center; display: flex; align-items:center; color: black; cursor:pointer; } #extendbar { position: absolute; bottom: 0px; height: 10px; width: 100%; line-height: 100%; color: black; cursor:pointer; } */ } function mycss(){ GM_addStyle(mycssinner.getMultilines()); } function initgoxpanel(){ $("body")[0].appendChild(goxpanel); $("body")[0].appendChild(goxpanelExtend); goxpanel.setAttribute('id','goxpanel'); goxpanel.style.setProperty('max-width', (document.body.clientWidth-1300)/2+'px'); goxpanel.innerHTML = '<div id="smallbar"><</div><div id="goxtip" class="goxtip"><a id="goxtiptext" title="设置刷新间隔"></a> </div> <div id="goxtipinfo" class="smalldiv"></div><div id="goxtipbottom" class="goxtip goxtipbottom smalldiv"><a id="goxtipbottomtext" title="设置主站域名"></a><input type="text" class="btn btn-details" placeholder="战斗历史" readonly="true" id="date"></div><div id="extendbar">∨</div>' //goxpanel.setAttribute('style','display: none;overflow-y:auto;'); ∧ $("#goxtip").append(autoconfigcheckboxdiv) $("#goxtipinfo").append(autoconfig); $("#goxtipinfo").append(progresschange); progresschange.style.setProperty("overflow-y","auto"); progresschange.style.setProperty("max-height","85%"); $("#goxtiptext").click(setflashtime); $("#smallbar").click(dosmalldiv); show_battle_log("主站域名:"+mainHost) $("#goxtipbottomtext").click(setmainHost); $("#extendbar").click(function(){ if($("#goxpanelExtend").css("display")=="none"){ $("#extendbar").text("∧") }else{ $("#extendbar").text("∨") } $("#goxpanelExtend").slideToggle(200); }); goxpanelExtend.innerHTML ='<input value="30" id="TopDuring" style="width: 40px;">日内 遇到最多TOP</input><input value="15" id="TopNum" style="width: 40px;margin-right:15px;"></input><input type="button" class="btn btn-details" value="查看" id="showTop"></input>' goxpanelExtend.setAttribute('id','goxpanelExtend'); goxpanelExtend.style.setProperty('max-width', (document.body.clientWidth-1300)/2+'px'); $("#showTop").click(function(){ var during = parseInt($("#TopDuring")[0].value) var num = parseInt($("#TopNum")[0].value) if(!(during>0)) return; if(!(num>0)) return; table_date_set(during,num) $("#chartParent").fadeIn(); mask.style.display = "block"; }) $("body")[0].appendChild(mask); mask.setAttribute('id','mask'); mask.addEventListener('click', function(){ $(".tc_xs").fadeOut(); $("#chartParent").fadeOut(); mask.style.display = "none"; }) $("body")[0].appendChild(detaillogpanel); detaillogpanel.setAttribute('class','tc_xs'); detaillogpanel.setAttribute('style','display: none;overflow-y:auto;'); var now = getLocDate() $("#date").datetime({ type: "date", value: [now.getFullYear(), now.getMonth()+1, now.getDate()], active:Object.keys(BattleLog), success: function (res) { detaillogpanelset(res) $(".tc_xs").fadeIn(); mask.style.display = "block"; } }) } function detaillogpanelset(key){ var text = ''; var divtext = '<div class="detaillogitem {0}"><div class="nameandlevel"><h3>{1}</h3></div><div style="display:none;">{2}</div></div>' var olddivtext = '<div class="detaillogitem {0}">{1}</div>'; var item = BattleLog[key]; if(item===undefined){ text+=divtext.format("","无数据"); }else{ var len=item.length; for(var i=len-1;i>=0;i--){ var thisclass = ''; if(item[i][1]){ thisclass="battlewin" }else { thisclass="battlelose" } if(item[i].length>2){ var name = get_enemylevel(item[i][2]) text+=divtext.format(thisclass,name,item[i][0]); }else{ text+=olddivtext.format(thisclass,item[i][0]); } } } detaillogpanel.innerHTML = text; $(".nameandlevel").click(function(){ $(this).next().toggle(200); }); } let observerBody1 = new MutationObserver(()=>{ var pkTextDiv = document.querySelector("#pk_text"); unsafeWindow.pkTextDiv = pkTextDiv; var enemydivs = pkTextDiv.querySelectorAll("h3.fyg_mp0"); if(enemydivs==null||enemydivs.length<2){return;} var enemyinfo = pkTextDiv.querySelectorAll("div.col-md-6")[1]; var isbattlewin = pkTextDiv.querySelectorAll(".icon-smile").length>0; var enemydiv = enemydivs[1]; var enemyname = enemydiv.innerText; var ename = enemyname.split("\n") console.log(enemyname) console.log(ename) logupdate(pkTextDiv,isbattlewin,ename[0]); if(ename[1].indexOf("野怪 Lv.")!=-1){return} if(mainHost!="0"){ get_user_theard(ename[0],enemydiv); } }); let observerBody2 = new MutationObserver(()=>{ var msg = $("#mymessagehtml").html(); if(msg == "星沙不足,本操作需 20 星沙"){ autoreStaminacheckbox.checked = false; changeLog.push(getNowtime() + " " + '星沙不足,回体失败') }else if(msg == "体力已刷新。"){ autoreStaminacheckbox.checked = false; changeLog.push(getNowtime() + " " + '消耗星沙恢复体力') }else if(msg == "今日刷新对手次数已达上限,每天可刷新 2 次。"){ autoreStaminacheckbox.checked = false; changeLog.push(getNowtime() + " " + '达到每日星沙恢复体力次数上限') } }); function logupdate(enemyinfo,isbattlewin,enemyname){ var etext = enemyinfo.innerHTML; var now = getLocDate(); var key = now.toLocaleDateString(); var a = BattleLog[key] if(a===undefined){ BattleLog[key]=[]; a = BattleLog[key] } a.push([etext,isbattlewin,enemyname]) FM_setValue("BattleLog",BattleLog) //updatelogpanel() } function save_enemylevel(name,level){ var a = BattleLog["enemylevel"] if(a===undefined){ BattleLog["enemylevel"]={}; a = BattleLog["enemylevel"] } a[name]=level; FM_setValue("BattleLog",BattleLog) } function get_enemylevel(name){ if(name.indexOf("等级 -")!=-1){return name} if(name.indexOf("ikarosf")!=-1){return name+"LV:"+57257*2} var a = BattleLog["enemylevel"] if(a===undefined){ return name; } if(name in a){ return name + "LV:" +a[name]; } return name } function dosmalldiv(){ if($(".smalldiv").css("display")=="none"){ $("#goxpanel").css("min-width","280px") $("#goxpanel").css("width","20%") $("#smallbar").text("<") localStorage.setItem("smalldiv","false") }else{ $("#goxpanel").css("min-width","unset") $("#goxpanel").css("width","50px") $("#smallbar").text(">") $("#goxpanelExtend").hide(); localStorage.setItem("smalldiv","true") } $(".smalldiv").toggle(); } function loadv(){ if(localStorage.getItem("smalldiv")=="true"){ dosmalldiv() } } function autodeletelog(){ var monthNumber = 30*24*60*60*1000; var now = getLocDate() for (var i in BattleLog){ var thisdate = new Date(i) //由于Date("enemylevel")返回的是当前的时间,所以不会被删除 if((now-thisdate)>monthNumber){ delete BattleLog[i]; } } FM_setValue("BattleLog",BattleLog) } function count_battle(during){ var during_s = during * 24 * 60 * 60 * 1000 var now = getLocDate() var enemy_sum = {}; for(var i in BattleLog){ if(i=="enemylevel") continue; var thisdate = new Date(i) if(now - thisdate > during_s) continue for(var j in BattleLog[i]){ if(BattleLog[i][j].length==3){ var name = BattleLog[i][j][2]; var isWin = BattleLog[i][j][1]; if(name.indexOf("等级 -")==-1){ var a = enemy_sum[name]; if(a==undefined){ enemy_sum[name] = [1,isWin?1:0,[i]]; }else{ enemy_sum[name][0]++; enemy_sum[name][1]+=isWin?1:0; enemy_sum[name][2].push(i); } } } } } var listSort = Object.keys(enemy_sum).sort(function(a,b){ return enemy_sum[b][0]-enemy_sum[a][0]; }); return [enemy_sum,listSort]; } function init_table(){ var table_html = '<canvas id="battleCountChart"></canvas>' var obj = document.createElement("div"); obj.innerHTML = table_html; obj.setAttribute('id','chartParent'); $("body")[0].appendChild(obj); chartssize(obj,ctx) } function table_date_set(during,num){ var count_result = count_battle(during) var enemy_sum = count_result[0]; var enemy_sum_top_list = count_result[1].slice(0, num) var count_list = [] for(var enemy_sum_top_item in enemy_sum_top_list){ count_list.push(enemy_sum[enemy_sum_top_list[enemy_sum_top_item]][1]) } $('#battleCountChart').remove(); $('#chartParent').append('<canvas id="battleCountChart"></canvas>'); var ctx = document.getElementById("battleCountChart") ctx.style.backgroundColor = 'rgba(250,250,250,150)'; var mybackgroundColor = [ 'rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)', 'rgba(255, 206, 86, 0.2)', 'rgba(75, 192, 192, 0.2)', 'rgba(153, 102, 255, 0.2)', 'rgba(255, 159, 64, 0.2)'] mybackgroundColor = mybackgroundColor.concat(mybackgroundColor) mybackgroundColor = mybackgroundColor.concat(mybackgroundColor) mybackgroundColor = mybackgroundColor.concat(mybackgroundColor) mybackgroundColor = mybackgroundColor.concat(mybackgroundColor) var myborderColor = [ 'rgba(255,99,132,1)', 'rgba(54, 162, 235, 1)', 'rgba(255, 206, 86, 1)', 'rgba(75, 192, 192, 1)', 'rgba(153, 102, 255, 1)', 'rgba(255, 159, 64, 1)'] myborderColor = myborderColor.concat(myborderColor) myborderColor = myborderColor.concat(myborderColor) myborderColor = myborderColor.concat(myborderColor) myborderColor = myborderColor.concat(myborderColor) var myChart = new Chart(ctx, { type: 'bar', data: { labels: enemy_sum_top_list, datasets: [{ label: '# of Votes', data: count_list, backgroundColor: mybackgroundColor, borderColor: myborderColor, borderWidth: 1 }] }, options: { scales: { yAxes: [{ ticks: { beginAtZero:true } }] }, responsive:true, maintainAspectRatio: false, title:{ display:true, text:'遇到最多的人TOP' + num, fontSize:25 }, legend: { display: false, }, tooltips: { intersect:false, displayColors:false, callbacks: { label: function(tooltipItem, data) { var enemy_name = tooltipItem.label var battle_sum = enemy_sum[enemy_name][0] var win_sum = enemy_sum[enemy_name][1] var label = ["战斗次数:"+battle_sum , "获胜次数:"+win_sum, "战斗日期:↓"]; for(var i in enemy_sum[enemy_name][2]){ label.push(" " + enemy_sum[enemy_name][2][i]) } return label; } } } } }); } //——————————————————mainfun———————————— unsafeWindow.get_user_theard = get_user_theard; observerBody1.observe(document.querySelector("#pk_text"), {characterData: true,childList: true}); observerBody2.observe(document.querySelector("#mymessagehtml"), {characterData: true,childList: true}); mycss(); initgoxpanel(); init_table(); autodeletelog(); loadv(); } function fyg_shop_html() { 'use strict'; var GachaLogPanel = document.createElement('div'); var detaillogpanel = document.createElement('div'); var mask = document.createElement('div'); var hisdiv = null; var todaydiv = null; var GachaLog = {} if(FM_getValue("GachaLog")!=null){ console.log("GachaLog load") GachaLog = FM_getValue("GachaLog"); } unsafeWindow.GachaLog = GachaLog; unsafeWindow.tzzzdjl = function(text1,text2){ logupdate(text1,text2) var tzzzdjl_t='<button class="btn btn-'+text2+' fyg_tc fyg_mp3" style="width:536px;"><i class="icon icon-bell-alt"></i> '+text1+'</button>'; $("#tzzzjl").prepend(tzzzdjl_t); } function logupdate(text1,text2){ var type = ""; var count = 0; var now = getLocDate(); count = parseInt(/\d+/.exec(text1)[0]) if(text1.indexOf("星沙")!=-1){ type="星沙"; } else if(text1.indexOf("贝壳")!=-1){ type="贝壳"; } else if(text1.indexOf("BVIP")!=-1){ type="BVIP"; } else if(text1.indexOf("SVIP")!=-1){ type="SVIP"; }else{ console.log("无类型!"); return; } var key = now.toLocaleDateString(); var a = GachaLog[key] if(a===undefined){ GachaLog[key]=[]; a = GachaLog[key] } a.push([type,count]) FM_setValue("GachaLog",GachaLog) updatelogpanel() } var GachaLogPanelinner = function () { /*<div class="tab-2"> <label for="tab2-1">历史</label> <input id="tab2-1" name="tabs-two" type="radio" checked="checked"> <div class="detail"> <div id="hisdiv"> </div> </div> <input type="text" class="btn btn-lg btn-primary btn-details" placeholder="详细" readonly="true" id="date"> </div> <div class="tab-2"> <label for="tab2-2">今日</label> <input id="tab2-2" name="tabs-two" type="radio"> <div class="detail"> <div id="todaydiv"> </div> </div> </div> */ }; var detaillogpanelinner = function () { /* 提示消息 */ }; function initGachaLogPanel(){ $("body")[0].appendChild(detaillogpanel); detaillogpanel.setAttribute('class','tc_xs'); detaillogpanel.setAttribute('style','display: none;overflow-y:auto;'); $("body")[0].appendChild(mask); mask.setAttribute('id','mask'); mask.addEventListener('click', function(){ $(".tc_xs").fadeOut(); mask.style.display = "none"; }) $(".panel-primary")[0].appendChild(GachaLogPanel); GachaLogPanel.setAttribute('class','tabs'); GachaLogPanel.innerHTML = GachaLogPanelinner.getMultilines(); hisdiv = $("#hisdiv")[0]; unsafeWindow.hisdiv = hisdiv; todaydiv = $("#todaydiv")[0]; var now = getLocDate() $("#date").datetime({ type: "date", value: [now.getFullYear(), now.getMonth()+1, now.getDate()], active:Object.keys(GachaLog), success: function (res) { detaillogpanelset(res) $(".tc_xs").fadeIn(); mask.style.display = "block"; } }) } function detaillogpanelset(key){ var text = ''; var divtext = '<div class="detaillogitem {0}">{1}</div><br>' var item = GachaLog[key]; if(item===undefined){ text+=divtext.format("","无数据"); }else{ var len=item.length; for(var i=len-1;i>=0;i--){ var thisclass = ''; if(item[i][0]=="SVIP"){ thisclass="svip" }else if(item[i][0]=="BVIP"){ thisclass="bvip" }else if(item[i][0]=="星沙"){ thisclass="xingsha" }else if(item[i][0]=="贝壳"){ thisclass="beike" } text+=divtext.format(thisclass,item[i][0]+":"+item[i][1]); } } console.log(text) detaillogpanel.innerHTML = text; } var mycssinner = function () { /* input::-webkit-input-placeholder{ color:#DCDCDC; } input:-moz-placeholder{ color:#DCDCDC; } input::-moz-placeholder{ color:#DCDCDC; } input:-ms-input-placeholder{ color:#DCDCDC; } .tabs { position:relative; min-height: 300px; display: block; display: -webkit-flex; display: -moz-flex; display: flex; -webkit-flex-wrap: wrap; -moz-flex-wrap: wrap; flex-wrap: wrap; margin: 10px; border: 1px solid #9370db; overflow: hidden; } .tabs [class^="tab"] label, .tabs [class*=" tab"] label { cursor: pointer; display: block; font-size: 1.1em; font-weight: 300; line-height: 1em; padding: 2rem 0; text-align: center; } .tabs [class^="tab"] [type="radio"], .tabs [class*=" tab"] [type="radio"] { cursor: pointer; -webkit-appearance: none; -moz-appearance: none; appearance: none; display: block; width: 100%; -webkit-transition: all 0.3s ease-in-out; -moz-transition: all 0.3s ease-in-out; -o-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; } .tabs [class^="tab"] [type="radio"]:hover, .tabs [class^="tab"] [type="radio"]:focus, .tabs [class*=" tab"] [type="radio"]:hover, .tabs [class*=" tab"] [type="radio"]:focus { border-bottom: 1px solid #40a9ff; } .tabs [class^="tab"] [type="radio"]:checked, .tabs [class*=" tab"] [type="radio"]:checked { border-bottom: 2px solid #40a9ff; } .tabs [class^="tab"] [type="radio"]:checked + div, .tabs [class*=" tab"] [type="radio"]:checked + div{ opacity: 1; } .tabs [class^="tab"] [type="radio"] + div, .tabs [class*=" tab"] [type="radio"] + div{ display: block; opacity: 0; padding: 2rem 0; width: 90%; -webkit-transition: all 0.3s ease-in-out; -moz-transition: all 0.3s ease-in-out; -o-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; } .tabs .tab-2 { width: 50%; } .tabs .tab-2 [type="radio"] + div { width: 200%; margin-left: 200%; } .tabs .tab-2 [type="radio"]:checked + div { margin-left: 0; } .tabs .tab-2:last-child [type="radio"] + div { margin-left: 100%; } .tabs .tab-2:last-child [type="radio"]:checked + div { margin-left: -100%; } #hisdiv,#todaydiv { display: block; font-size: 1.3em; font-weight: 150; line-height: 1em; padding: 10px 10px; //text-align: center; } .detail{ } .btn-details { display: block; width: 45%; position:absolute; bottom:5px; left:5px; } .tc_xs{ width:30%; height:60%; line-height:3rem; background:#666; position:fixed; left:50%; margin-left:-15%; bottom:30%; text-align:center; color:#fff; border-radius:4px; display:none; z-index:10; } #mask{ display:none; width:100%; height:200%; position:absolute; top:0; left:0; z-index:1; background-color:#000; opacity:0.3; } .detaillogitem{ display:inline-block; padding: 10px 16px; width:60%; margin-top:5px; background-color:#333; border-radius:4px; } .svip{ background-color:#ea644a; } .bvip{ background-color:#0a67fb; } .xingsha{ background-color:#26762a; } .beike{ background-color:#333; } */ }; function mycss(){ GM_addStyle(mycssinner.getMultilines()); } function updatelogpanel(){ var now = getLocDate(); var hissum = {"消耗星晶":0,"星沙":0,"贝壳":0,"BVIP":0,"SVIP":0,},nowsum={"消耗星晶":0,"星沙":0,"贝壳":0,"BVIP":0,"SVIP":0,} for (var key in GachaLog) { var item = GachaLog[key]; for(var i in item){ hissum['消耗星晶']++; hissum[item[i][0]]+=item[i][1]; if(now.toLocaleDateString()==key){ nowsum['消耗星晶']++; nowsum[item[i][0]]+=item[i][1]; } } } var histext = makedictText(hissum) var nowtext = makedictText(nowsum) hisdiv.innerText = histext; todaydiv.innerText = nowtext; } function makedictText(dict){ var text = ''; for(var key in dict) { var item = dict[key]; text+=key text+=":" text+=item text+="\n" } return text } initGachaLogPanel(); mycss(); updatelogpanel() } function dictsort(dic){ var res = Object.keys(dic).sort(function(a,b){return b-a;}); for(var key in res){ console.log("key: " + res[key] + " ,value: " + dic[res[key]].score); } } Function.prototype.getMultilines = function () { var lines = new String(this); lines = lines.substring(lines.indexOf("/*") + 2,lines.lastIndexOf("*/")); return lines; } String.format = function(src){ if (arguments.length == 0) return null; var args = Array.prototype.slice.call(arguments, 1); return src.replace(/\{(\d+)\}/g, function(m, i){ return args[i]; }); }; function FM_setValue(name, value){ var oldvalue = GM_getValue(user); if(oldvalue === undefined){ oldvalue = {};} oldvalue[name] = value; GM_setValue(user,oldvalue); } function FM_getValue(name, defaultValue){ var thisvalue = GM_getValue(user); if(thisvalue != undefined&&name in thisvalue){ return thisvalue[name] } if(defaultValue != null){ return defaultValue; } return null; } function html_encode(str) { var s = ""; if (str.length == 0) return ""; s = str.replace(/&/g, "&"); s = s.replace(/</g, "<"); s = s.replace(/>/g, ">"); s = s.replace(/ /g, " "); s = s.replace(/\'/g, "'"); s = s.replace(/\"/g, """); s = s.replace(/\n/g, "<br/>"); return s; } function html_decode(str) { var s = ""; if (str.length == 0) return ""; s = str.replace(/&/g, "&"); s = s.replace(/</g, "<"); s = s.replace(/>/g, ">"); s = s.replace(/ /g, " "); s = s.replace(/'/g, "\'"); s = s.replace(/"/g, "\""); s = s.replace(/<br\/>/g, "\n"); return s; } function getLocDate(){ //本地时间 + 本地时间与格林威治时间的时间差 + GMT+8与格林威治的时间差 return new Date(new Date().getTime() + new Date().getTimezoneOffset()*60*1000 + 8*60*60*1000) } //参数container为图表盒子节点.charts为图表节点 function chartssize (container,charts) { function getStyle(el, name) { if (window.getComputedStyle) { return window.getComputedStyle(el, null); } else { return el.currentStyle; } } var wi = getStyle(container, 'width').width; var hi = getStyle(container, 'height').height; charts.style.width = wi charts.style.height = hi } //——————————————————mainfun———————————— var user = document.getElementsByClassName('icon-user')[0].parentNode.innerText.split(' ')[1]; let dateTimecss = GM_getResourceText('dateTimecss') var startindex = dateTimecss.indexOf("@charset") var endindex = dateTimecss.indexOf("endmycss")-1 GM_addStyle(html_decode(dateTimecss.slice(startindex,endindex))) var rl = window.location.href; if(/guguzhen.com\/fyg_pk.php/.test(rl)){ fyg_pk_html(); } /*if(/guguzhen.com\/fyg_shop.php/.test(rl)){ fyg_shop_html(); }*/ unsafeWindow.GM_getValue = GM_getValue