// ==UserScript== // @name B站游戏wiki ——【支线任务标记】(烟雨江湖、 崩坏:星穹铁道) // @namespace https://greasyfork.org/users/3128 // @version 0.3.2 // @description 对H3任务标题添加【任务标记】、【内容折叠】功能,以便于了解自己完成的任务。对树桩、宝箱添加标记功能,记录领取状态。 // @author 极品小猫 // @match https://wiki.biligame.com/yanyu/* // @match https://wiki.biligame.com/sr/* // @exclude https://wiki.biligame.com/yanyu/%E6%B8%B8%E6%88%8F%E6%94%AF%E7%BA%BF // @require https://cdn.staticfile.org/jquery/2.1.4/jquery.min.js // @grant GM_setValue // @grant GM_getValue // @grant GM_addStyle // @grant GM_setClipboard // @grant GM_xmlhttpRequest // @grant unsafeWindow // @grant GM_notification // @grant GM_registerMenuCommand // @license MIT // @run-at document-idle // @downloadURL none // ==/UserScript== (function() { 'use strict'; let u=unsafeWindow, webHost=location.host.toLowerCase(), webPath=location.pathname.toLowerCase(); switch(webHost) { case 'wiki.biligame.com': let wgPageName = u?.RLCONF?.wgPageName || u?.mw?.config.get('wgPageName') || null; if(!wgPageName) alert(`加载基础数据失败,请刷新页面。`); let wgGameName = wgPageName.wgGameName; //游戏Wiki名 let GM_Config_Task=GM_getValue(wgPageName); //创建数据储存容器 if(!GM_Config_Task) if(localStorage[wgPageName]) { GM_Config_Task=JSON.parse(localStorage[wgPageName]); GM_setValue(wgPageName, GM_Config_Task); delete localStorage[wgPageName]; } else GM_Config_Task={}; GM_addStyle(`input[title="任务完成标记"]{width:80px;height80px}`); let Bind={ InputClick : (e)=>{ // @Rank = 归类 //console.log(this, e); if(e.data.Rank) { if(!GM_Config_Task[e.data.Rank]) GM_Config_Task[e.data.Rank]={}; GM_Config_Task[e.data.Rank][e.data.key]=e.target.checked; } else GM_Config_Task[e.data.key]=e.target.checked; GM_setValue(wgPageName, GM_Config_Task); } } switch(wgGameName) { case 'yanyu': if(webPath.includes('%E7%AD%94%E9%A2%98%E8%BE%85%E5%8A%A9')) { let t=setInterval(function(e){ if($('.form-control.searcher-text').length>0) { $('.form-control.searcher-text').focus(function(){ console.log($(this).select()); $(this).select(); }); clearInterval(t); } }, 1000); } //树桩、宝箱添加标记框 $('#TbPn-shuzhuang .wikitable tr:not(:first-child), #TbPn-baoxiang .wikitable tr:not(:first-child)').each(function(i, e){ let td=$(''), boxPosition= $(this).find('td:nth-child(2)').text().trim(), //获取树桩、宝箱坐标 checkBox = $('').attr({id:`checkBox_${boxPosition}`}).on('click', {key: boxPosition, Rank: '资源'}, Bind.InputClick); checkBox.prop('checked', GM_Config_Task?.['资源']?.[boxPosition]); console.log(GM_Config_Task?.['资源']?.[boxPosition]); $(this).append(td.append(checkBox)); }); break; } //遍历任务导航,添加任务标记框 let toclevel; for(let i=2;i>0;i--) { //console.log(i, `.toclevel-${i}`, document.querySelector(`.toclevel-${i}`)); if(document.querySelector(`.toclevel-${i}`)) { toclevel=`.toclevel-${i}`; break; } } if(toclevel) $(toclevel).each(function(i, e){ //遍历二级标题 let this_toc=this; let taskTitleID=$(this).find('a[href^="#"]').attr('href').replace('#',''), taskInputID=`checkTask_${taskTitleID}`; //使用任务锚点作为任务ID,避免出现同名任务 let checkTask=$('').attr({id:taskInputID}).click(function(e, aa){ GM_Config_Task[taskTitleID]=this.checked; GM_setValue(wgPageName, GM_Config_Task); if(this.checked) $(this_toc).append(''); else $(this_toc).find(':last-child').remove(); }); //插入任务完成标记Input if(!document.querySelector(`#${taskInputID}`)) $(`#${taskTitleID}`).before(checkTask); let label=$('