From e401643d910c396864652193a92204692b140c11 Mon Sep 17 00:00:00 2001 From: manchuwork Date: Fri, 12 Dec 2025 04:26:16 +0800 Subject: [PATCH] copy red dot --- script-copy-source-red-dot.js | 125 ++++++++++++++++++++++++++++++++++ script2-1-qcc-acq.js | 2 + 2 files changed, 127 insertions(+) create mode 100644 script-copy-source-red-dot.js diff --git a/script-copy-source-red-dot.js b/script-copy-source-red-dot.js new file mode 100644 index 0000000..2b01f8a --- /dev/null +++ b/script-copy-source-red-dot.js @@ -0,0 +1,125 @@ + +// ==UserScript== +// @name HTML Source Dot +// @namespace http://tampermonkey.net/ +// @version 1.0 +// @description Minimal HTML source viewer with draggable red dot +// @author YourName +// @match *://*/* +// @grant GM_setClipboard +// @run-at document-start +// ==/UserScript== + +(function() { + 'use strict'; + + // 创建小红点元素 + const dot = document.createElement('div'); + dot.id = 'source-dot'; + dot.style.cssText = ` + position: fixed; + top: 20px; + left: 20px; + width: 16px; + height: 16px; + background: #ff4444; + border-radius: 50%; + cursor: move; + z-index: 99999; + box-shadow: 0 0 4px rgba(0,0,0,0.3); + transition: all 0.2s ease; + `; + + // 创建隐藏的源码容器 + const sourceContainer = document.createElement('div'); + sourceContainer.id = 'source-container'; + sourceContainer.style.cssText = ` + display: none; + position: fixed; + z-index: 99998; + background: white; + border: 1px solid #ddd; + border-radius: 4px; + padding: 8px; + max-width: 80vw; + max-height: 80vh; + overflow: auto; + font-family: monospace; + font-size: 12px; + `; + + // 添加到文档 + document.documentElement.appendChild(dot); + document.documentElement.appendChild(sourceContainer); + + // 拖拽功能 + let isDragging = false; + let offsetX, offsetY; + + dot.addEventListener('mousedown', function(e) { + if (e.button !== 0) return; // 只响应左键 + isDragging = true; + offsetX = e.clientX - dot.getBoundingClientRect().left; + offsetY = e.clientY - dot.getBoundingClientRect().top; + dot.style.cursor = 'grabbing'; + }); + + document.addEventListener('mousemove', function(e) { + if (!isDragging) return; + dot.style.left = (e.clientX - offsetX) + 'px'; + dot.style.top = (e.clientY - offsetY) + 'px'; + }); + + document.addEventListener('mouseup', function() { + isDragging = false; + dot.style.cursor = 'move'; + }); + + // 悬停效果 + dot.addEventListener('mouseenter', function() { + dot.style.transform = 'scale(1.5)'; + dot.style.background = '#4CAF50'; + dot.title = 'Click to copy HTML'; + }); + + dot.addEventListener('mouseleave', function() { + dot.style.transform = ''; + dot.style.background = '#ff4444'; + dot.title = ''; + }); + + // 点击复制功能 + dot.addEventListener('click', function() { + const html = document.documentElement.outerHTML; + GM_setClipboard(html, 'text'); + + // 显示临时提示 + sourceContainer.textContent = 'HTML copied to clipboard!'; + sourceContainer.style.display = 'block'; + sourceContainer.style.left = (parseInt(dot.style.left) + 20) + 'px'; + sourceContainer.style.top = dot.style.top; + + setTimeout(() => { + sourceContainer.style.display = 'none'; + }, 1500); + }); + + // 立即显示小红点 + dot.style.display = 'block'; + + // 持续更新源码(即使在加载过程中) + const updateSource = () => { + sourceContainer.textContent = document.documentElement.outerHTML; + }; + + // 初始获取 + updateSource(); + + // 定时更新 + const interval = setInterval(updateSource, 300); + window.addEventListener('DOMContentLoaded', () => { + clearInterval(interval); + updateSource(); + }); + window.addEventListener('load', updateSource); +})(); diff --git a/script2-1-qcc-acq.js b/script2-1-qcc-acq.js index 42cf5a4..6814985 100644 --- a/script2-1-qcc-acq.js +++ b/script2-1-qcc-acq.js @@ -1179,6 +1179,8 @@ class TianYanChaParser { // 复制源码按钮 const copySourceButton = createButton("复制源码", () => { const html = document.documentElement.outerHTML; + + //ToolUtils.copyToClipboard(html, "源码已复制到剪贴板"); GM_setClipboard(html, 'text'); ToolUtils.showAutoCloseMessage("源码已复制到剪贴板", "success") });