multi insert nodes

5/31/2025, 8:50:16 AM

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        multi insert nodes
// @namespace   Violentmonkey Scripts
// @match       https://www.cs.usfca.edu/~galles/visualization/RedBlack.html
// @grant       window
// @version     1.0
// @author      s4n7r0
// @description 5/31/2025, 8:50:16 AM
// @license     MIT
// @grant GM_addElement
// ==/UserScript==

function insert_multiple() {
    values = currentAlg.insertField.value.split(",").filter((x) => x.length).map((x) => x.trim())
    currentAlg.animationManager.addListener("AnimationEnded", currentAlg, insert_single)
    currentAlg.insertField.value = values.shift()
    AlgorithmSpecificControls.children[1].children[0].click()
    return;
}

function insert_single(e) {

    currentAlg.insertField.value = values.shift()
    AlgorithmSpecificControls.children[1].children[0].click()
    if (values.length <= 0) {
        currentAlg.animationManager.removeListener("AnimationEnded", currentAlg, insert_single)
        //console.log("i have quit!")
    }
    return currentAlg.enableUi(e)
}

var values = []
let element1 = GM_addElement(AlgorithmSpecificControls.children[1], "input", {id: "insert-multiple", type: "button", value: "Multi Insert"});

element1.onclick = () => insert_multiple()