// ==UserScript==
// @name 点击特效(所有网站适用!)
// @namespace http://tampermonkey.net/
// @version 7.8
// @description 点击释放蓝色特效!长按有惊喜哦
// @author Super_Diu
// @match *://*/*
// @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant none
// ==/UserScript==
(function() {
'use strict';
function clickTriangleEffect() {
let triangles = []; // 存储三角形实例
let chargeDots = []; // 存储长按蓄力小圆点实例
let canvas, ctx;
let width, height; // 画布宽高
// 纯蓝色系配色
const blueColors = ["#1E90FF", "#4169E1", "#00BFFF", "#87CEFA", "#6495ED", "#0099FF", "#7B68EE"];
// 三角形类型
const triTypes = ["acute", "right", "obtuse", "isosceles", "equilateral"];
// 尾迹轨迹点(粗糙不卡顿)
const MAX_TRACK_POINTS = 10;
const DOT_TRACK_POINTS = 5;
// 长按核心参数
let pressStartTime = 0;
let isPressing = false;
let pressX = 0, pressY = 0;
const LONG_PRESS_THRESHOLD = 1000;
// 进阶特效上限
const MAX_SIZE = 20;
const MAX_SPEED = 15;
const MIN_ALPHA_SPEED = 8;
// 三角形数量随长按递增
const BASE_CREATE_COUNT = 12;
const MAX_CREATE_COUNT = 30;
const COUNT_SCALE_DURATION = 3000;
// 蓄力小圆点配置
const CHARGE_DOT_RADIUS_MIN = 1;
const CHARGE_DOT_RADIUS_MAX = 3;
const CHARGE_DOT_SPAWN_INTERVAL = 150;
const CHARGE_DOT_INIT_SPEED = 0.6;
const CHARGE_DOT_ACCEL = 0.1;
const CHARGE_DOT_ALPHA_SPEED = 0.02;
const CHARGE_DOT_FADE_SPEED_BASE = 0.03; // 圆点基础消失速度
const CHARGE_DOT_SPAWN_RADIUS_MIN = 120;
const CHARGE_DOT_SPAWN_RADIUS_MAX = 200;
// 新增:速度关联消失的系数(仅快一点,0.002为宜,越大速度影响越明显)
const SPEED_ALPHA_FACTOR = 0.0001;
let lastDotSpawnTime = 0;
// 创建画布
canvas = document.createElement("canvas");
document.body.appendChild(canvas);
canvas.setAttribute("style", "width: 100%; height: 100%; top: 0; left: 0; z-index: 99999; position: fixed; pointer-events: none;");
// 初始化画布
if (canvas.getContext && window.addEventListener) {
ctx = canvas.getContext("2d");
updateCanvasSize();
window.addEventListener('resize', updateCanvasSize, false);
requestAnimationFrame(loop);
// 鼠标事件
window.addEventListener("mousedown", function(e) {
isPressing = true;
pressStartTime = Date.now();
pressX = e.clientX;
pressY = e.clientY;
lastDotSpawnTime = Date.now();
}, false);
window.addEventListener("mouseup", createEffectByPress, false);
window.addEventListener("mouseout", function() {
isPressing = false;
pressStartTime = 0;
chargeDots.forEach(dot => dot.needFade = true);
}, false);
} else {
console.log("当前浏览器不支持Canvas或addEventListener!");
}
// 画布大小更新
function updateCanvasSize() {
canvas.width = window.innerWidth * 2;
canvas.height = window.innerHeight * 2;
canvas.style.width = window.innerWidth + 'px';
canvas.style.height = window.innerHeight + 'px';
ctx.scale(2, 2);
width = window.innerWidth;
height = window.innerHeight;
}
// 工具方法
function alphaToHex(alpha) {
const hex = Math.floor(Math.max(0, Math.min(255, alpha * 255))).toString(16);
return hex.length === 1 ? '0' + hex : hex;
}
function randBetween(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function randFloat(min, max) {
return Math.random() * (max - min) + min;
}
// 生成三角形特效
function createEffectByPress() {
if (!isPressing) return;
const pressDuration = Date.now() - pressStartTime;
isPressing = false;
pressStartTime = 0;
chargeDots.forEach(dot => dot.needFade = true);
let baseSizeMin = 7, baseSizeMax = 13;
let baseSpeedMin = 4, baseSpeedMax = 9;
let baseAlphaSpeedMin = 25, baseAlphaSpeedMax = 35;
let createCount = BASE_CREATE_COUNT;
if (pressDuration >= LONG_PRESS_THRESHOLD) {
const overThreshold = pressDuration - LONG_PRESS_THRESHOLD;
const scale = Math.min(1, overThreshold / COUNT_SCALE_DURATION);
createCount = Math.floor(BASE_CREATE_COUNT + scale * (MAX_CREATE_COUNT - BASE_CREATE_COUNT));
baseSizeMax = 13 + scale * (MAX_SIZE - 13);
baseSpeedMax = 9 + scale * (MAX_SPEED - 9);
baseAlphaSpeedMin = 25 - scale * (25 - MIN_ALPHA_SPEED);
baseAlphaSpeedMax = 35 - scale * (35 - MIN_ALPHA_SPEED);
}
// 生成三角形时,根据随机速度调整透明衰减速度(速度越快消失稍快)
for (let i = 0; i < createCount; i++) {
const triSpeed = randBetween(baseSpeedMin, baseSpeedMax);
// 基础衰减速度 + 速度关联的增量(仅快一点,不突兀)
let triAlphaSpeed = randBetween(baseAlphaSpeedMin, baseAlphaSpeedMax);
triAlphaSpeed = triAlphaSpeed + triSpeed * 2; // 系数2,速度越快增量越大,可微调
triAlphaSpeed = Math.min(triAlphaSpeed, 50); // 限制上限,防止消失过快
triangles.push(new Triangle(
pressX, pressY,
randBetween(baseSizeMin, baseSizeMax),
triSpeed,
triAlphaSpeed / 1000
));
}
}
// 蓄力小圆点类(彻底修复穿位 + 速度越快消失越快)
class ChargeDot {
constructor(targetX, targetY) {
this.targetX = targetX;
this.targetY = targetY;
const radius = randFloat(CHARGE_DOT_SPAWN_RADIUS_MIN, CHARGE_DOT_SPAWN_RADIUS_MAX);
const angle = randFloat(0, Math.PI * 2);
this.x = targetX + Math.cos(angle) * radius;
this.y = targetY + Math.sin(angle) * radius;
this.r = randFloat(CHARGE_DOT_RADIUS_MIN, CHARGE_DOT_RADIUS_MAX);
this.color = blueColors[Math.floor(Math.random() * blueColors.length)];
this.alpha = 0;
this.speed = CHARGE_DOT_INIT_SPEED;
this.accel = CHARGE_DOT_ACCEL;
this.needFade = false;
this.angle = Math.atan2(targetY - this.y, targetX - this.x);
this.trackPoints = [];
this.isArrived = false; // 到达标记
}
addTrackPoint() {
if (this.isArrived) return;
this.trackPoints.push({ x: this.x, y: this.y, alpha: this.alpha, r: this.r });
if (this.trackPoints.length > DOT_TRACK_POINTS) this.trackPoints.shift();
}
update() {
if (this.isArrived) {
this.alpha = 0;
return;
}
this.addTrackPoint();
// 核心:速度越快,消失/显隐的速度稍快(蓄力/松鼠标均生效)
const speedFactor = 1 + this.speed * SPEED_ALPHA_FACTOR;
if (this.needFade) {
// 松鼠标:消失速度 = 基础速度 * 速度系数(仅快一点)
this.alpha = Math.max(0, this.alpha - CHARGE_DOT_FADE_SPEED_BASE * speedFactor);
} else {
// 蓄力中:显隐速度 = 基础速度 * 速度系数(快一点变实)
this.alpha = Math.min(1, this.alpha + CHARGE_DOT_ALPHA_SPEED * speedFactor);
}
// 彻底修复穿位:提前判定+强制停移(比原阈值更保守,杜绝加速冲过)
const dx = this.targetX - this.x;
const dy = this.targetY - this.y;
const distance = Math.sqrt(dx * dx + dy * dy);
// 判定阈值:圆点半径的1.5倍(更保守,适配加速度),触碰即停
if (distance > this.r * 1.5) {
this.speed += this.accel;
// 额外限制最大速度,防止速度过高冲过
this.speed = Math.min(this.speed, 5); // 最大速度5,可微调
this.x += Math.cos(this.angle) * this.speed;
this.y += Math.sin(this.angle) * this.speed;
} else {
this.isArrived = true;
this.alpha = 0;
this.trackPoints = [];
}
}
drawTrail() {
if (this.trackPoints.length < 2 || this.alpha <= 0 || this.isArrived) return;
ctx.save();
ctx.beginPath();
ctx.moveTo(this.trackPoints[0].x, this.trackPoints[0].y);
for (let i = 1; i < this.trackPoints.length; i++) {
ctx.lineTo(this.trackPoints[i].x, this.trackPoints[i].y);
}
const lineWidth = this.r * 0.3;
if (lineWidth <= 0) return;
const gradient = ctx.createLinearGradient(
this.trackPoints[0].x, this.trackPoints[0].y,
this.trackPoints[this.trackPoints.length-1].x, this.trackPoints[this.trackPoints.length-1].y
);
gradient.addColorStop(0, `${this.color}1A`);
gradient.addColorStop(1, `${this.color}${alphaToHex(Math.min(0.6, this.alpha))}`);
ctx.lineWidth = lineWidth;
ctx.lineCap = "butt";
ctx.lineJoin = "miter";
ctx.strokeStyle = gradient;
ctx.stroke();
ctx.restore();
}
draw() {
if (this.alpha <= 0 || this.isArrived) return;
this.drawTrail();
ctx.save();
ctx.globalAlpha = this.alpha;
ctx.fillStyle = this.color;
ctx.beginPath();
ctx.arc(this.x, this.y, this.r, 0, Math.PI * 2);
ctx.closePath();
ctx.fill();
ctx.restore();
}
}
// 三角形类(速度越快消失越快 + 原有尖角尾迹/顶端透明度匹配)
class Triangle {
constructor(x, y, size, speed, alphaSpeed) {
this.x = x;
this.y = y;
this.angle = Math.random() * Math.PI * 2;
this.speed = speed; // 保存当前速度,用于后续可能的扩展
this.rotateSpeed = (Math.random() - 0.5) * 18;
this.currentRotate = 0;
this.size = size;
this.color = blueColors[Math.floor(Math.random() * blueColors.length)];
this.type = triTypes[Math.floor(Math.random() * triTypes.length)];
this.alpha = 1;
this.alphaSpeed = alphaSpeed; // 已由外部根据速度调整,直接使用
this.sizeSpeed = randBetween(5, 12) / 100;
this.trackPoints = [];
}
update() {
this.addTrackPoint();
this.x += Math.cos(this.angle) * this.speed;
this.y += Math.sin(this.angle) * this.speed;
this.currentRotate += this.rotateSpeed;
this.size = Math.max(1, this.size - this.sizeSpeed);
// 直接使用调整后的衰减速度,速度越快alphaSpeed越大,消失越快
this.alpha = Math.max(0, this.alpha - this.alphaSpeed);
}
addTrackPoint() {
this.trackPoints.push({ x: this.x, y: this.y, size: this.size, alpha: this.alpha });
if (this.trackPoints.length > MAX_TRACK_POINTS) this.trackPoints.shift();
}
drawSingle(ctx, x, y, rotate, size, alpha) {
if (alpha <= 0 || size <= 0) return;
ctx.save();
ctx.globalAlpha = alpha;
ctx.translate(x, y);
ctx.rotate(rotate * Math.PI / 180);
ctx.fillStyle = this.color;
ctx.beginPath();
switch (this.type) {
case "acute": ctx.moveTo(0, -size); ctx.lineTo(size * 0.6, size * 0.8); ctx.lineTo(-size * 0.6, size * 0.8); break;
case "right": ctx.moveTo(0, -size * 0.7); ctx.lineTo(size * 0.7, size * 0.7); ctx.lineTo(-size * 0.7, size * 0.7); break;
case "obtuse": ctx.moveTo(0, -size); ctx.lineTo(size * 0.9, size * 0.5); ctx.lineTo(-size * 0.9, size * 0.5); break;
case "isosceles": ctx.moveTo(0, -size); ctx.lineTo(size * 0.5, size * 0.9); ctx.lineTo(-size * 0.5, size * 0.9); break;
case "equilateral": const h = size * Math.sqrt(3) / 2; ctx.moveTo(0, -h / 2); ctx.lineTo(size / 2, h / 2); ctx.lineTo(-size / 2, h / 2); break;
}
ctx.closePath();
ctx.fill();
ctx.restore();
}
drawTrail(ctx) {
if (this.trackPoints.length < 2 || this.alpha <= 0) return;
ctx.save();
const trailCount = this.trackPoints.length;
ctx.beginPath();
ctx.moveTo(this.trackPoints[0].x, this.trackPoints[0].y);
for (let i = 1; i < trailCount; i++) {
ctx.lineTo(this.trackPoints[i].x, this.trackPoints[i].y);
}
const maxLineWidth = this.trackPoints[trailCount-1].size * 0.6;
const minLineWidth = this.trackPoints[0].size * 0.3;
ctx.lineWidth = (maxLineWidth + minLineWidth) / 2;
ctx.lineCap = "butt";
ctx.lineJoin = "miter";
const gradient = ctx.createLinearGradient(
this.trackPoints[0].x, this.trackPoints[0].y,
this.trackPoints[trailCount-1].x, this.trackPoints[trailCount-1].y
);
gradient.addColorStop(0, `${this.color}26`);
gradient.addColorStop(1, `${this.color}${alphaToHex(this.alpha)}`);
ctx.strokeStyle = gradient;
ctx.stroke();
ctx.restore();
}
draw() {
if (this.alpha <= 0) return;
this.drawTrail(ctx);
this.drawSingle(ctx, this.x, this.y, this.currentRotate, this.size, this.alpha);
}
}
// 动画循环
function loop() {
ctx.clearRect(0, 0, width, height);
if (isPressing) {
const pressDuration = Date.now() - pressStartTime;
if (pressDuration >= LONG_PRESS_THRESHOLD) {
const now = Date.now();
if (now - lastDotSpawnTime >= CHARGE_DOT_SPAWN_INTERVAL) {
chargeDots.push(new ChargeDot(pressX, pressY));
lastDotSpawnTime = now;
}
}
}
// 圆点更新绘制
chargeDots.forEach(dot => dot.update());
chargeDots.forEach(dot => dot.draw());
chargeDots = chargeDots.filter(dot => dot.alpha > 0 && !dot.isArrived);
// 三角形更新绘制
triangles.forEach(tri => tri.update());
triangles.forEach(tri => tri.draw());
triangles = triangles.filter(tri => tri.alpha > 0);
requestAnimationFrame(loop);
}
}
// 调用特效
clickTriangleEffect();
})();点击特效(所有网站适用!)
这是 2026年2月3日 存档的第 3 版,不是当前版本。查看当前版本