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.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 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);
})();