您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Adds a button with which you can change the color of the SVG before downloading.
当前为
// ==UserScript== // @name Simpleicons.org Dynamic Color Button // @namespace https://greasyfork.org/ // @version 0.0.1 // @description Adds a button with which you can change the color of the SVG before downloading. // @author Ap // @match https://simpleicons.org/* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Wait until the DOM is fully loaded window.addEventListener('DOMContentLoaded', function() { // Find the download button element by its ID let downloadBtn = document.getElementById('icon-download-color-svg'); if (downloadBtn) { // Create a new <a> element let promptBtn = document.createElement('a'); // Copy the attributes from the original button promptBtn.download = downloadBtn.download; promptBtn.href = downloadBtn.href; // Add new attributes to the new button promptBtn.setAttribute('class', 'detail-button'); promptBtn.setAttribute('id', 'icon-download-color-svg-prompt'); promptBtn.setAttribute('role', 'button'); // Insert the new button next to the original one downloadBtn.parentNode.insertBefore(promptBtn, downloadBtn.nextSibling); // Add click event listener to the new button promptBtn.addEventListener('click', function(event) { event.preventDefault(); // Prevent the default action // Get the hex code from the user let hexCode = prompt("Please enter hex code for color."); // Check if the hex code is valid if (hexCode && /^([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/i.test(hexCode)) { // Replace the fill value in the href attribute with the new hex code promptBtn.href = downloadBtn.href.replace(/fill=%23[0-9a-fA-F]{6}/, `fill=%23${hexCode}`); // Trigger the download window.location.href = promptBtn.href; } else { alert('Invalid hex code entered.'); } }); } }); })();