// ==UserScript== // @name Base64编码解码工具 // @namespace http://tampermonkey.net/ // @version 1.2 // @description 支持base64编码和解码,并可自动填充选中内容,支持折叠和拖拽,默认最小化 // @match *://*/* // @grant GM_addStyle // ==/UserScript== (function() { 'use strict'; // 添加样式,使用更具体的选择器 GM_addStyle(` #base64-tool-container { position: fixed; top: 20px; right: 20px; z-index: 9999999; font-family: Arial, sans-serif; } #base64-tool-container * { box-sizing: border-box; } #base64-tool { background: #ffffff; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); padding: 15px; width: 300px; transition: all 0.3s ease; } #base64-tool.minimized { width: 100px; height: 40px; overflow: hidden; padding: 5px; } #base64-tool textarea { width: 100%; height: 80px; padding: 8px; margin: 5px 0; border: 1px solid #ced4da; border-radius: 4px; resize: vertical; } #base64-tool button { width: 48%; padding: 8px; margin: 5px 1%; background: #007bff; color: white; border: none; border-radius: 4px; cursor: pointer; transition: background 0.3s; } #base64-tool button:hover { background: #0056b3; } #base64-toggle-btn { position: absolute; top: 5px; right: 5px; width: 30px; height: 30px; background: #007bff; color: white; border: none; border-radius: 50%; cursor: pointer; font-size: 16px; font-weight: bold; z-index: 1; display: flex; align-items: center; justify-content: center; transition: all 0.3s ease; } #base64-tool-content { margin-top: 30px; } #base64-drag-handle { cursor: move; padding: 5px; background: #f0f0f0; border-bottom: 1px solid #ddd; margin: -15px -15px 10px -15px; border-radius: 8px 8px 0 0; } `); // 创建容器和工具界面 const container = document.createElement('div'); container.id = 'base64-tool-container'; const tool = document.createElement('div'); tool.id = 'base64-tool'; tool.className = 'minimized'; // 默认最小化 tool.innerHTML = `