Greasy Fork

来自缓存

Greasy Fork is available in English.

wolai Plus

略略略~

当前为 2020-12-09 提交的版本,查看 最新版本

// ==UserScript==
// @name         wolai Plus
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  略略略~
// @author       Liuser
// @include      https://www.wolai.com/*
// @grant        none
// ==/UserScript==

(function () {

    let svgItem = ""
    let svgItemChildPage = ""
    let config = {
        attributes: true
    };
    let mouseClick = new MouseEvent("click", {
        bubbles: true,
        cancelable: true,
        view: window,
    });
    let getElementAll = function () {
        svgItem = document.getElementsByClassName('_3skBI _1LKlS')[0].children[0]
        svgItemChildPage = document.getElementsByClassName('_2Q7F8 _2xbd4 vCtLm')[1]
    }
    var callback = function (mutationsList) {
        for (let mutation of mutationsList) {
            if (mutation.type == 'attributes') {
                getElementAll()
                console.log('切换了页面')
            }

        }
    };
    let observer = new MutationObserver(callback);
    setTimeout(function () { //延迟5秒
        getElementAll()
        'use strict';
        document.onkeydown = function () {
            if ((window.event.altKey) && ((window.event.keyCode == 78))) {
                console.log('直接新建页面')
                svgItem.dispatchEvent(mouseClick)
            }
            if ((window.event.ctrlKey) && ((window.event.keyCode == 77))) {
                console.log('新建子页面')
                svgItemChildPage.dispatchEvent(mouseClick)
            }
        }
        observer.observe(svgItemChildPage, config);
    }, 5 * 1000);

})();