【脚本】双击右键复制勋章图片
本帖最后由 Makima 于 2025-10-5 10:44 编辑双击右键勋章(GIF图片
会自动复制 插入图片的链接
适用于勋章放大镜
https://img.gamemale.com/album/202410/26/190035r9q4q3hgi3ngxqgq.gif
@Name @Match // ==UserScript==
// @name 双击右键复制gif
// @version 0.1
// @author MKM
// @match https://www.gamemale.com/*
// @grant GM_setClipboard
// ==/UserScript==
(function() {
'use strict';
let lastRightClickTime = 0;
let lastRightClickTarget = null;
document.addEventListener('contextmenu', function(event) {
const target = event.target;
if (target.tagName === 'IMG' && isGifImage(target)) {
const currentTime = Date.now();
if (currentTime - lastRightClickTime < 500 && lastRightClickTarget === target) {
event.preventDefault();
event.stopPropagation();
const formattedText = `${target.src}`;
GM_setClipboard(formattedText, 'text');
showNotification('✅已复制', event.clientX, event.clientY);
}
lastRightClickTime = currentTime;
lastRightClickTarget = target;
} else {
lastRightClickTarget = null;
}
}, true);
function isGifImage(imgElement) {
if (!imgElement.src) return false;
const src = imgElement.src.toLowerCase();
if (src.endsWith('.gif') || src.includes('.gif?')) {
return true;
}
if (imgElement.srcset && imgElement.srcset.toLowerCase().includes('.gif')) {
return true;
}
try {
const url = new URL(src, window.location.href);
return url.pathname.toLowerCase().endsWith('.gif');
} catch {
return false;
}
}
function showNotification(message, x, y) {
const notification = document.createElement('div');
notification.style.cssText = `
position: fixed;
left: ${x + 10}px;
top: ${y + 10}px;
background: #4CAF50;
color: white;
padding: 8px 12px;
border-radius: 4px;
z-index: 100000;
font-family: Arial, sans-serif;
font-size: 12px;
font-weight: bold;
box-shadow: 0 2px 8px rgba(0,0,0,0.3);
transition: all 0.3s ease;
pointer-events: none;
`;
notification.textContent = message;
document.body.appendChild(notification);
setTimeout(() => {
notification.style.opacity = '0';
notification.style.transform = 'translateY(-10px)';
setTimeout(() => notification.remove(), 300);
}, 1000);
}
})();
这个用起来还是挺方便的, 非常感谢大佬!效果:
https://img.gamemale.com/album/202306/15/220534osku6fxfv95cxvak.gif
有几个小问题:
第一就是脚本里
// @authoe MKM 是不是写错了(应该没有影响
// @author MKM
第二是右键通常会触发浏览器右键上下文菜单, 导致真想复制图片链接得甩狙, 也就是第二下需要鼠标想左划一下,有没有更好的鼠标触发模式呢:shutup:当然样兼容性更好了, 确实也方便 以前的勋章总结帖子,本人都是右键复制图片地址来操作的,反正都是用纯文本模式编辑,这个脚本可以少点击几步 乌萨奇老师也开始主攻小插件了吗,感觉很实用的样子呢 还挺方便的说,不过对我这种懒人还是抄作业更方便;P 这个确实很不错哎,感觉以后更方便在勋章博物馆回帖了 感觉很适合勋章博物馆的回帖,但是新的勋章没有抢到多少:'( 我能不能在勋章纪念馆发帖取决于我的网速和手速。。。插件还是挺实用的。 右键双击复制图片还是蛮方便的,有些勋章卡面好看的想要收藏一下:loveliness: 直接把老公的徽章图片收藏起来厚{:6_163:} 感谢大佬分享,很实用的手势功能,mark一下 很适合用来介绍新的勋章 感谢分享 这下喜欢的勋章图片可以很方便的保存下来了,很实用的功能 复制勋章图片咩~倒是方便下载自己喜欢的卡面 https://images2.imgbox.com/be/9d/XZMEcAGi_o.gif所以有没有大佬用这个脚本把放大镜更新一下 求求了 很方便哎,可以保存自己喜欢的卡面了,感谢楼主分享 很多勋章的图片确实是很不错 https://img.gamemale.com/album/202508/27/154618wt52fzit25qb9aaf.jpg适合在勋章博物馆回帖呢 不过我应该是抢不到沙发位的 有点像是咸鱼老大的勋章复制功能~想收藏勋章图片确实挺实用~感谢大佬分享惹呢;P 最近研究插件全是关于勋章的 收下了 感谢大佬
页:
[1]
2