NovelAI Use Anlas Alert

On NovelAI's image generation screen, change the color of the generate button to a warning color when there are Anlas to be used.

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         NovelAI Use Anlas Alert
// @name:ja      NovelAI Anlas使用警告
// @name:en      NovelAI Use Anlas Alert
// @namespace    https://github.com/Takenoko3333/NAI-use-anlas-alert
// @version      1.1.0
// @description  On NovelAI's image generation screen, change the color of the generate button to a warning color when there are Anlas to be used.
// @description:ja  NovelAIの画像生成画面において、消費するAnlasがある場合に生成ボタンの色を警告色に変更します。
// @description:en  On NovelAI's image generation screen, change the color of the generate button to a warning color when there are Anlas to be used.
// @author       Takenoko3333
// @match        https://novelai.net/image
// @icon         https://www.google.com/s2/favicons?sz=64&domain=novelai.net
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    const useAnlas = '.sc-4f026a5f-2 div div span';
    const warningColor = 'orangered';

    setInterval(() => {
        document.querySelectorAll(useAnlas).forEach(element => {
            if (element && element.textContent.trim() !== '0') {
                element.style.color = warningColor;
                element.parentNode.parentNode.parentNode.style.backgroundColor = warningColor;
                element.parentNode.nextElementSibling.style.backgroundColor = warningColor;
            } else {
                element.style.color = '';
                element.parentNode.parentNode.parentNode.style.backgroundColor = '';
                element.parentNode.nextElementSibling.style.backgroundColor = '';
            }
        });
    }, 500);
})();