// ==UserScript==
// @name 悬浮菜单 - 脚本管理工具
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 添加悬浮菜单,支持脚本管理功能
// @author Your name
// @match *://*/*
// @grant GM_setValue
// @grant GM_getValue
// ==/UserScript==
(function() {
'use strict';
// 数据结构定义
const scriptData = {
groups: GM_getValue('scriptGroups', [])
};
// 替换所有的 localStorage 操作
function saveData() {
GM_setValue('scriptGroups', scriptData.groups);
}
// 更新样式
const style = document.createElement('style');
style.textContent = `
.floating-btn {
position: fixed;
right: 20px;
bottom: 20px;
z-index: 9999;
padding: 3px;
background: #ffffff;
cursor: move;
user-select: none;
border: 1px solid #dcdfe6;
color: #108ee9;
font-size: 14px;
min-width: 30px;
text-align: center;
transition: all 0.3s;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.menu-container {
display: none;
position: fixed;
background: white;
border: 1px solid #dcdfe6;
border-radius: 3px;
padding: 10px;
z-index: 9999;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.menu-btn {
display: block;
width: 100%;
padding: 8px;
margin: 5px 0;
border: none;
background: #4CAF50;
color: white;
border-radius: 3px;
cursor: pointer;
}
.menu-btn:hover {
background: #45a049;
}
.right-drawer {
position: fixed;
top: 0;
right: -540px;
width: 540px;
height: 100%;
background: white;
box-shadow: rgba(0,0,0,0.08) 0 16px 48px 16px,rgba(0,0,0,0.12) 0 12px 32px 0,rgba(0,0,0,0.16) 0 8px 16px -8px;
transition: right 0.3s ease;
z-index: 9999;
}
.script-tree {
height: calc(100% - 82px);
overflow-y: auto;
margin: 0 20px;
padding-bottom: 12px;
}
.tree-node {
outline: none;
white-space: nowrap;
}
.tree-node-content {
display: flex;
align-items: center;
height: 32px;
cursor: pointer;
padding-left: 0;
}
.tree-node-content:hover {
background: #f5f7fa;
}
.script-actions button {
padding: 0;
font-size: 12px;
color: #409eff;
background: none;
border: none;
cursor: pointer;
margin-left: 12px;
}
.script-actions button:hover {
color: #79bbff;
}
.dialog-overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 10000;
display: flex;
align-items: center;
justify-content: center;
}
.dialog {
background: white;
padding: 20px;
border-radius: 4px;
min-width: 300px;
box-shadow: 0 2px 12px 0 rgba(0,0,0,0.1);
}
.dialog-header {
margin-bottom: 20px;
font-size: 16px;
font-weight: 500;
}
.dialog-content {
margin-bottom: 20px;
}
.dialog input {
width: 100%;
padding: 8px 12px;
border: 1px solid #dcdfe6;
border-radius: 4px;
font-size: 14px;
transition: border-color 0.2s;
box-sizing: border-box;
}
.dialog input:focus {
outline: none;
border-color: #409eff;
}
.dialog-footer {
text-align: right;
}
.dialog-btn {
padding: 8px 20px;
margin-left: 10px;
border-radius: 4px;
font-size: 14px;
cursor: pointer;
border: 1px solid #dcdfe6;
}
.dialog-btn.primary {
background: #409eff;
border-color: #409eff;
color: white;
}
.dialog-btn.default {
background: white;
color: #606266;
}
.icon {
width: 16px;
height: 16px;
display: inline-flex;
align-items: center;
justify-content: center;
margin-right: 4px;
}
.folder-icon {
color: #909399;
}
.script-icon {
color: #409EFF;
}
.action-btn {
padding: 2px 8px;
font-size: 12px;
color: #409EFF;
background: none;