您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Draws a perfect circle
- // ==UserScript==
- // @name Perfect Circle Drawer
- // @namespace example.com
- // @version 1.0
- // @description Draws a perfect circle
- // @author You
- // @match *://*/* # Change this to match the desired website
- // @grant GM_addStyle
- // @grant none
- // ==/UserScript==
- function drawCircle(x, y, radius, color) {
- // Get the canvas element or create one dynamically
- let canvas = document.getElementById('myCanvas');
- if (!canvas) {
- canvas = document.createElement('canvas');
- canvas.id = 'myCanvas';
- canvas.width = 400; // Adjust as needed
- canvas.height = 400; // Adjust as needed
- document.body.appendChild(canvas); // Add to the page
- }
- let ctx = canvas.getContext('2d');
- ctx.beginPath();
- ctx.arc(x, y, radius, 0, 2 * Math.PI);
- ctx.fillStyle = color;
- ctx.fill();
- }
- // Add a button or use a keyboard shortcut
- const button = document.createElement('button');
- button.textContent = 'Draw Circle';
- button.addEventListener('click', function() {
- // Example: Draw a circle at (100, 100) with radius 50 and red color
- drawCircle(100, 100, 50, 'red');
- });
- document.body.appendChild(button);