MEST Batch Delete

美尔斯通批量删除

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         MEST Batch Delete
// @namespace    joyings.com.cn
// @version      0.1
// @description  美尔斯通批量删除
// @author       zmz125000
// @match        http://*/mest/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=92.133
// @grant        none
// @license        MIT
// ==/UserScript==

(function () {
    'use strict';

    // Your code here...
    function deleteNext() {
        if (document.querySelectorAll('[class="el-button table-operation el-button--default el-button--mini"]').length == 0) {
            alert("finished");
            return 1;
        }
        document.querySelectorAll('[class="el-button table-operation el-button--default el-button--mini"]')[1].click();
        setTimeout(function () {
            document.querySelectorAll('[class="el-button el-button--default el-button--small el-button--primary "]')[0].click();
        }, 100);
        window.setTimeout(deleteNext, 500);
    };

    function deleteOnce() {
        document.querySelectorAll('[class="el-button table-operation el-button--default el-button--mini"]')[1].click();
        setTimeout(function () {
            document.querySelectorAll('[class="el-button el-button--default el-button--small el-button--primary "]')[0].click();
        }, 100);
    };

    window.addEventListener('load', function () {
        var btn = document.createElement('button');
        btn.setAttribute('title', '批量删除表体项目,使用前请先筛选');
        btn.setAttribute('type', 'button')
        btn.appendChild(document.createTextNode('BatchDelete'));
        btn.onclick = deleteNext;
        document.querySelector('[class="ml15"]').appendChild(btn);
    });

    function waitForElm(selector) {
        return new Promise(resolve => {
            if (document.querySelector(selector)) {
                return resolve(document.querySelector(selector));
            }
            const observer = new MutationObserver(mutations => {
                if (document.querySelector(selector)) {
                    resolve(document.querySelector(selector));
                    observer.disconnect();
                }
            });
            observer.observe(document.body, {
                childList: true,
                subtree: true
            });
        });
    };
})();