您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
从 GlyphWiki editor 下载 SVG 的脚本
当前为
// ==UserScript== // @name GlyphWiki SVG 下載器 // @name:en GlyphWiki SVG Downloader // @name:zh-CN GlyphWiki SVG 下载器 // @name:ja GlyphWiki SVG ダウンローダー // @namespace http://tampermonkey.net/ // @version 1.5.0.1 // @description 從 GlyphWiki editor 下載 SVG 的腳本 // @description:en A script to download SVG code from GlyphWiki editor // @description:zh-CN 从 GlyphWiki editor 下载 SVG 的脚本 // @description:ja GlyphWikiエディタからSVGをダウンロードするスクリプト // @author SoizoKtantas & ChatGPT // @match https://glyphwiki.org/kage-editor/* // @grant none // @icon https://glyphwiki.org/kage-editor/favicon.ico // @license Apache License 2.0 // ==/UserScript== (function () { "use strict"; window.addEventListener("load", function () { var parentElement = document.querySelector( "#root > div > div.editor-controls > div.preview" ); if (parentElement) { var downloadButton = document.createElement("button"); downloadButton.textContent = getTranslation("saveSVG"); downloadButton.onclick = function () { var svgElement = document.querySelector( "#root > div > div.editor-controls > div.preview > svg" ); if (svgElement) { svgElement.setAttribute( "xmlns", "http://www.w3.org/2000/svg" ); svgElement.setAttribute("version", "1.1"); var fileName = prompt( getTranslation("enterFileName"), "glyphwiki" ); if (!fileName) { alert(getTranslation("fileNameEmpty")); return; } var svgData = new Blob([svgElement.outerHTML], { type: "image/svg+xml;charset=utf-8", }); var svgUrl = URL.createObjectURL(svgData); var downloadLink = document.createElement("a"); downloadLink.href = svgUrl; downloadLink.download = fileName + ".svg"; document.body.appendChild(downloadLink); downloadLink.click(); document.body.removeChild(downloadLink); URL.revokeObjectURL(svgUrl); } else { alert(getTranslation("svgNotFound")); } }; parentElement.appendChild(downloadButton); } else { alert(getTranslation("elementNotFound")); } }); function getTranslation(key) { var lang = navigator.language || navigator.userLanguage; lang = lang.replace('-', '_'); // 將 zh-CN 轉換為 zh_CN 等 console.log(lang) var translations = { en: { saveSVG: "Save SVG Image", enterFileName: "Enter file name:", fileNameEmpty: "File name cannot be empty", svgNotFound: "SVG image not found", elementNotFound: "Target element not found", }, zh_CN: { saveSVG: "保存SVG图像", enterFileName: "输入文件名:", fileNameEmpty: "文件名不能为空", svgNotFound: "找不到SVG图像", elementNotFound: "找不到目标元素", }, zh_TW: { saveSVG: "保存SVG圖像", enterFileName: "輸入文件名:", fileNameEmpty: "文件名不能為空", svgNotFound: "找不到SVG圖像", elementNotFound: "找不到目標元素", }, ja: { saveSVG: "SVG画像を保存", enterFileName: "ファイル名を入力:", fileNameEmpty: "ファイル名は空にできません", svgNotFound: "SVG画像が見つかりません", elementNotFound: "対象要素が見つかりません", }, }; var translation = translations[lang] || translations[lang.split('_')[0]] || translations.en; return translation[key]; } })();