您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Chants script for NovelAI
当前为
// ==UserScript== // @name Chants for NovelAI // @namespace https://www6.notion.site/dc99953d5f04405c893fba95dace0722 // @version 1 // @description Chants script for NovelAI // @author SenY // @match https://novelai.net/image // @icon https://www.google.com/s2/favicons?sz=64&domain=novelai.net // @grant none // @license MIT // ==/UserScript== (function() { const getChantURL = function(force){ if(force === true){ localStorage.removeItem("chantURL"); } let chantURL = localStorage.getItem("chantURL") || prompt("Input your chants json url.\nThe URL must be a Cors-enabled server (e.g., gist.github.com).", "https://gist.githubusercontent.com/vkff5833/989808aadebf8648831955cdf2a7b3e3/raw/yuuri.json"); if(chantURL){ localStorage.setItem("chantURL", chantURL); } return chantURL; } let chantURL = getChantURL(null); let ui = document.createElement("div"); document.body.appendChild(ui); ui.style.position = "fixed"; ui.style.right = "0px"; ui.style.bottom = "0px"; ui.style.zIndex = "32768"; ui.style.maxWidth = "25%"; const Build = function(){ ui.textContent = ""; let button = document.createElement("button"); button.textContent = "Reset Chants URL"; button.style.color = "red"; button.addEventListener("click", function(){ chantURL = getChantURL(true); Build(); }); ui.appendChild(button); let hr = document.createElement("hr"); hr.style.color = "grey"; hr.style.borderWidth = "2px"; ui.appendChild(hr); let chants = []; const Append = function(key) { let chant = chants.find(x => x.name == key.trim()); if(chant){ document.querySelector("textarea[placeholder]").value += ", "+chant.content; } } fetch(chantURL, { method: "GET", }).then((response) => response.json()) .then((data) => { chants = data; chants.forEach(chant => { let button = document.createElement("button"); button.textContent = chant.name; button.style.color = "black"; button.addEventListener("click", function(){ Append(chant.name); }); ui.appendChild(button); }); }); } let init = false; document.addEventListener("DOMContentLoaded", function(){ if(init === false){ Build(); init = true; } }); })();