Toffu

Autofills Woffu schedule

当前为 2021-05-28 提交的版本,查看 最新版本

// ==UserScript==
// @name         Toffu
// @namespace    http://yelidmod.com/trendier
// @version      0.3
// @description  Autofills Woffu schedule
// @author       DonNadie
// @match        https://*.woffu.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('load', () => {
        const observer = new MutationObserver(() => {
            $modal.querySelectorAll('input').forEach((input, i) => {
                if (input.value.length < 1) {
                    input.focus();
                    input.value = input.placeholder.substr(0, 5); // from 19:00:00 to 19:00
                    input.dispatchEvent(new Event('change'));
                }
            });
        });
        const $modal = document.getElementById('diary-edit');

        if ($modal != null) {
            observer.observe($modal, {
                childList: true,
                subtree: true
            });
        }
    }, false);
})();