// ==UserScript==
// @name COC阵型复制助手
// @namespace https://github.com/RiTian96/SurfHelper
// @version 1.1.3
// @description [核心] 绕过付费/次数限制,后台无感提取阵型链接;[辅助] 鼠标悬停显示高清巨型大图(自适应尺寸,智能避让鼠标);[资源] 左侧悬浮背包记录历史阵型,支持二维码扫码直连。
// @author RiTian96
// @match *://coc.6oh.cn/*
// @icon https://coc.6oh.cn/favicon.ico
// @icon https://www.google.com/s2/favicons?sz=64&domain=coc.6oh.cn
// @grant GM_addStyle
// @grant GM_setClipboard
// @run-at document-start
// @license MIT
// @updateURL https://raw.githubusercontent.com/RiTian96/SurfHelper/main/tampermonkey-scripts/coc-layout-helper.user.js
// @downloadURL https://raw.githubusercontent.com/RiTian96/SurfHelper/main/tampermonkey-scripts/coc-layout-helper.user.js
// ==/UserScript==
(function() {
'use strict';
/**
* =================================================================
* 1. 全局配置 (Configuration)
* =================================================================
*/
const CONFIG = {
// 历史记录最大保存条数
bagMaxItems: 50,
// 是否开启调试日志
debug: false
};
// 运行时状态管理
const State = {
historyLog: [], // 历史记录存储
currentBtn: null, // 当前操作的按钮
isLensVisible: false // 透镜显示状态
};
const log = (...args) => CONFIG.debug && console.log('🛡️ COC Helper:', ...args);
/**
* =================================================================
* 2. 样式注入 (CSS Injection)
* =================================================================
*/
function injectStyles() {
GM_addStyle(`
/* --- [核心] 屏蔽干扰 --- */
/* 隐藏 layui 的遮罩和弹窗 (付费/登录提示) */
.layui-layer-shade, .layui-layer-dialog, .layui-layer-msg {
display: none !important; z-index: -9999 !important; pointer-events: none !important;
}
/* --- [视觉] 成功反馈 --- */
.coc-cracked-card {
border: 3px solid #00E676 !important; /* 绿色高亮 */
box-shadow: 0 0 15px rgba(0, 230, 118, 0.4) !important;
transform: scale(1.01);
transition: all 0.3s ease;
z-index: 5;
position: relative;
}
/* --- [组件] 智能巨型透镜 (Magic Lens) - 自适应版 --- */
#coc-magic-lens {
position: fixed;
top: 50%;
/* left/right 由 JS 动态控制以避让鼠标 */
transform: translateY(-50%);
/* 自适应逻辑:取消固定宽高,改用最大限制 */
width: auto;
height: auto;
max-width: 48vw; /* 限制宽度不超过屏幕一半 (留出鼠标空间) */
max-height: 90vh; /* 限制高度不超过屏幕90% */
background: rgba(0, 0, 0, 0.95);
border: 2px solid #555;
border-radius: 12px;
box-shadow: 0 30px 100px rgba(0,0,0,0.9); /* 强阴影提升层次感 */
z-index: 2147483647; /* 使用最高z-index确保在最上层 */
/* 布局居中,消除黑边关键 */
display: none;
flex-direction: column;
align-items: center;
justify-content: center;
pointer-events: none; /* 关键:鼠标穿透 */
backdrop-filter: blur(5px);
transition: opacity 0.2s;
will-change: opacity; /* 优化性能 */
}
#coc-magic-lens img {
display: block;
max-width: 100%;
max-height: 85vh; /* 确保图片完整显示,留出边距 */
object-fit: contain;
opacity: 0;
transition: opacity 0.3s ease;
user-select: none; /* 防止图片被选中 */
-webkit-user-drag: none; /* 防止拖拽 */
}
/* 加载提示 */
#coc-magic-lens::after {
content: "高清原图读取中...";
position: absolute;
color: #888; font-size: 12px; letter-spacing: 1px;
z-index: 1; /* 确保文字可见 */
pointer-events: none;
}
/* --- [组件] 侧边背包 (Loot Bag) --- */
#coc-loot-bag {
position: fixed; top: 25%; left: 0;
width: 40px; height: auto;
background: rgba(20, 20, 20, 0.98);
border-radius: 0 10px 10px 0;
z-index: 100000;
border: 1px solid #444; border-left: none;
box-shadow: 2px 2px 10px rgba(0,0,0,0.5);
transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
overflow: hidden; cursor: pointer;
}
#coc-loot-bag:hover { width: 260px; }
.bag-icon-area {
width: 40px; height: 50px;
display: flex; align-items: center; justify-content: center;
font-size: 20px; color: #bbb; background: rgba(255,255,255,0.05);
}
#coc-loot-list {
width: 260px; max-height: 400px; overflow-y: auto;
}
#coc-loot-list::-webkit-scrollbar { width: 4px; }
#coc-loot-list::-webkit-scrollbar-thumb { background: #555; border-radius: 2px; }
.coc-loot-item {
font-size: 12px; color: #ccc; padding: 12px 15px;
border-bottom: 1px solid #333; transition: background 0.2s;
white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.coc-loot-item:hover { background: #333; color: #00E676; }
/* --- [组件] 结果弹窗 (Modal) --- */
#coc-result-modal {
position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
background: rgba(25, 25, 25, 0.98); backdrop-filter: blur(10px);
color: #fff; padding: 25px; border-radius: 16px;
z-index: 2147483647; width: 340px; max-width: 90vw; text-align: center;
box-shadow: 0 25px 80px rgba(0,0,0,0.8); border: 1px solid #444;
animation: popUp 0.25s ease-out; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
will-change: transform, opacity;
}
@keyframes popUp {
from {transform:translate(-50%,-45%) scale(0.95);opacity:0;}
to {transform:translate(-50%,-50%) scale(1);opacity:1;}
}
/* 链接文本域 (自动换行) */
.coc-link-textarea {
width: 100%; height: 70px;
background: #111; border: 1px solid #444; color: #00E676;
font-size: 12px; font-family: Consolas, monospace;
padding: 8px; margin: 10px 0; border-radius: 6px;
resize: none; outline: none; word-break: break-all; white-space: pre-wrap;
box-sizing: border-box; text-align: left;
}
`);
}
/**
* =================================================================
* 3. 组件初始化 (Initialization)
* =================================================================
*/
function initComponents() {
// 1. 巨型透镜
const lens = document.createElement('div');
lens.id = 'coc-magic-lens';
lens.innerHTML = '';
document.body.appendChild(lens);
// 2. 侧边背包
const bag = document.createElement('div');
bag.id = 'coc-loot-bag';
bag.innerHTML = `
链接已自动复制: