HuangQS

自用,一些页面的优化

目前為 2024-03-20 提交的版本,檢視 最新版本

// ==UserScript==
// @name         HuangQS
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @description  自用,一些页面的优化
// @author       You
// @match        *://*/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 获取当前页面的URL
    const currentURL = window.location.href;

    // 亡灵增量
    if (currentURL.includes('www.mhhf.com') || currentURL.includes('www.json1.cn')) {
        document.title = '测试-Canvas绘制展示';

        setInterval(()=>{
            // 找到包含所有按钮的父元素
            let spellsContainer = document.querySelector('.spells');

            // 找到所有按钮元素
            let spellButtons = spellsContainer? spellsContainer.querySelectorAll('.spell') : undefined;

            // 循环点击每个按钮
            if(spellButtons){
                for(let i =0 ; i<spellButtons.length ; i++){
                    //仅点击前两个
                    if(i>=2)break;
                    let button = spellButtons[i];
                    // 触发点击事件
                    button.dispatchEvent( new MouseEvent('click', { bubbles: true,cancelable: true, view: window }));
                }

            }
        },1000)

    }

    //json在线解析去广告 进入后全屏
    else if (currentURL.includes('www.json.cn')) {
        document.title = 'JSON';

        // 找到对应的按钮元素 触发点击事件
        let clickEvent = new MouseEvent('click', { bubbles: true, cancelable: true, view: window });
        document.getElementById('formatFullScreen').dispatchEvent(clickEvent);
    }
    //文本比对 进入后全屏
    else if(currentURL.includes('https://tool.lu/diff')){
        let clickEvent = new MouseEvent('click', { bubbles: true, cancelable: true, view: window });
        document.getElementById('js-webfullscreen').dispatchEvent(clickEvent);
    }

})();