Capytale : Restart & clear outputs in just 1 button

Ras le bol de devoir cliquer sur Noyau, Redémarrer & tout exécuter, Valider, puis encore Noyau, Redémarrer & effacer les sorties ...

目前為 2024-10-30 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Capytale : Restart & clear outputs in just 1 button
// @namespace    http://tampermonkey.net/
// @version      2024-10-30
// @description  Ras le bol de devoir cliquer sur Noyau, Redémarrer & tout exécuter, Valider, puis encore Noyau, Redémarrer & effacer les sorties ...
// @author       You
// @include      https://capytale2.ac-paris.fr/p/basthon/**
// @icon         https://www.favicon.studio/favicon.ico
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // Fonction qui redémarre le noyau, exécute tout, efface les sorties
    function restartAndClean() {
        // Redémarrer et tout exécuter
        document.querySelector('#restart_run_all').click();
        setTimeout(()=>{
            document.querySelector('.modal-footer .btn-danger').click();
            // Redémarrer et effacer les sorties
            setTimeout(()=>{
                document.querySelector('#restart_clear_output').click();
                setTimeout(()=>{
                    document.querySelector('.modal-footer .btn-danger').click();
                }, 500)
            }, 500)
        }, 500)
    }

    // Créer un nouveau bouton
    let btnEl = document.createElement('button');
    btnEl.className = 'btn btn-default';
    btnEl.title = 'Tout exécuter + Effacer les sorties';
    btnEl.innerHTML = '<i class="fa-truck fa"></i>';
    btnEl.addEventListener('click', restartAndClean);

    // On attend le bon moment pour ajouter notre bouton
    let ticTac;
    function myCallback() {
        if (document.querySelector('#MathJax_Message')) {
            clearInterval(ticTac);
            document.querySelector('#RISE').insertAdjacentElement('afterend', btnEl);
        }
    }
    ticTac = setInterval(myCallback, 500);


})();