B站游戏wiki —— 烟雨江湖【支线任务标记】

自用

目前为 2023-03-09 提交的版本。查看 最新版本

// ==UserScript==
// @name         B站游戏wiki —— 烟雨江湖【支线任务标记】
// @namespace      https://gf.qytechs.cn/users/3128
// @version      0.2.2
// @description  自用
// @author       You
// @match        https://wiki.biligame.com/yanyu/*
// @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
// ==/UserScript==
 
(function() {
    'use strict';
 
    let u=unsafeWindow,
        webHost=location.host.toLowerCase(),
        webPath=location.pathname.toLowerCase();
 
    let web={
    }
 
    switch(webHost) {
        case 'wiki.biligame.com':
            if(webPath.search('%E7%AD%94%E9%A2%98%E8%BE%85%E5%8A%A9'.toLowerCase())>0){
                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);
            }
 
            let wgPageName=u.RLCONF.wgPageName||u.mw.config.get('wgPageName')||null;
            if(!wgPageName) alert(`加载基础数据失败,请刷新页面。`);
            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);
                }
            }

            //$('h2>#Ø_支线任务').nextAll();
            $('.toclevel-2').each(function(i, e){ //遍历二级标题
                let this_toc=this;
                console.log(this);
                let taskTitle=$(this).find('span.toctext').first().text();
                let checkTask=$('<input type="checkbox" title="任务完成标记">').attr({id:`checkTask_${taskTitle}`}).click(function(e, aa){
                    GM_Config_Task[taskTitle]=this.checked;
                    GM_setValue(wgPageName, GM_Config_Task);
                    if(this.checked) $(this_toc).append('<span>√</span>');
                    else $(this_toc).find(':last-child').remove();
                });
                console.log($(`#`+taskTitle));
                $(`#${taskTitle}`).before(checkTask);
 
                let label=$('<label>').attr({for:`checkTask_${taskTitle}`}).text(taskTitle);
                $(`#${taskTitle}`).parent().find('.mw-headline').html(label); //在标题前插入复选框

                let headLineBox=$(`#${taskTitle}`).parent(); //任务标题获得父容器
                let headLineBox_ContentBox=$(`<div data-taskTitle="${taskTitle}">`);
                headLineBox_ContentBox.append(headLineBox.nextUntil('h2, h3')); //遍历获得父容器间的内容,并填充


                headLineBox.click(()=>{
                    headLineBox_ContentBox.toggle();
                }); //为标题父容器添加折叠事件


                headLineBox_ContentBox.insertAfter(headLineBox);
                //读取任务状态
                if(GM_Config_Task[taskTitle]) {
                    checkTask.prop('checked', GM_Config_Task[taskTitle]||false); //变更配置数据
                    $(this).append('√'); //添加任务状态
                    headLineBox_ContentBox.hide(); //隐藏掉任务内容
                }
            });
            $('#TbPn-shuzhuang .wikitable tr:not(:first-child), #TbPn-baoxiang .wikitable tr:not(:first-child)').each(function(i, e){
                let td=$('<td>'),
                    boxPosition= $(this).find('td:nth-child(2)').text().trim(), //获取树桩、宝箱坐标
                    checkBox = $('<input type="checkBox" title="标记物品已领取">').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;
        default :
            /*
            GM_xmlhttpRequest({
                url:'',
                method: 'get',
 
                onload: function(e){
                    console.log(e);
                },
                onerror: function(e){
                    console.error('error', e);
                }
            });
            */
    }
 
    // Your code here...
    function getUrlParam(name, url, option, newVal) {//筛选参数,url 参数为数字时
        var search = url ? url.replace(/^.+\?/,'') : location.search;
        //网址传递的参数提取,如果传入了url参数则使用传入的参数,否则使用当前页面的网址参数
        var reg = new RegExp("(?:^|&)(" + name + ")=([^&]*)(?:&|$)", "i");		//正则筛选参数
        var str = search.replace(/^\?/,'').match(reg);
 
        if (str !== null) {
            switch(option) {
                case 0:
                    return unescape(str[0]);		//所筛选的完整参数串
                case 1:
                    return unescape(str[1]);		//所筛选的参数名
                case 2:
                    return unescape(str[2]);		//所筛选的参数值
                case 'new':
                    return url.replace(str[1]+'='+str[2], str[1]+'='+newVal);
                default:
                    return unescape(str[2]);        //默认返回参数值
            }
        } else {
            return null;
        }
    }
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址