做了个油猴脚本,可以在复制外链的时候自由选择内网还是外链;目前脚本是根据自己需求做的,如需改动,请自己联系ai改动;发出来看看有没有其他人需要;
需要手动替换自己的飞牛内网地址;不支持https;
效果如图:

油猴脚本如下,需要自行脚本中的更改内网ip部分:
// ==UserScript==
// @name 飞牛NAS分享链接自动替换成内网
// @namespace http://tampermonkey.net/
// @version 1.7
// @description 复制外链分享时,弹出选择对话框,可选替换为内网链接或不更改;
// @match http://192.168.1.1:5666/*
// ^ 请自行修改 IP 和端口
// @match /^https?:\/\/(10\..*|172\.(1[6-9]|2[0-9]|3[0-1])\..*|192\.168\..*)/
// @grant none
// @run-at document-start
// ==/UserScript==
(function() {
'use strict';
// 插入全局样式,用于左上角 Toast
const style = document.createElement('style');
style.textContent = `
.tm-toast {
position: fixed;
top: 20px;
left: 20px;
background: rgba(0, 0, 0, 0.75);
color: #fff;
padding: 8px 16px;
border-radius: 4px;
font-size: 14px;
opacity: 0;
transition: opacity 0.2s ease-in-out;
z-index: 9999;
white-space: nowrap;
}
.tm-toast.show {
opacity: 1;
}
`;
document.head.appendChild(style);
// 创建并显示一个自动消失的 Toast(默认 2000ms)
function showToast(msg, duration = 2000) {
const toast = document.createElement('div');
toast.className = 'tm-toast';
toast.textContent = msg;
document.body.appendChild(toast);
/* 强制重排 */
toast.offsetWidth;
toast.classList.add('show');
setTimeout(() => {
toast.classList.remove('show');
toast.addEventListener('transitionend', () => toast.remove(), { once: true });
}, duration);
}
// 匹配第一个 /s/ 链接,返回 match 对象
function matchShareLink(text) {
return text.match(/https?:\/\/[^\/]+(\/s\/\S*)/i);
}
document.addEventListener('copy', e => {
let raw = '';
const sel = window.getSelection();
if (sel && !sel.isCollapsed) {
raw = sel.toString();
} else if (document.activeElement && /(INPUT|TEXTAREA)/.test(document.activeElement.tagName)) {
raw = document.activeElement.value;
} else {
return; // 没有选中任何文本,直接退出
}
const m = matchShareLink(raw);
if (!m) {
return; // 选中的文本里不包含分享链接,使用默认复制
}
// 弹出选择:确定 = 内网,取消 = 外网
const copyInternal = confirm('点击“确定”更改为内网链接;点击“取消”不更改');
// 如果选外网,则让浏览器执行默认复制,不修改 clipboardData
if (!copyInternal) {
showToast('已复制外网链接');
return;
}
// 下面是“内网链接”分行格式化
const originalLink = m[0]; // 原始外网链接
const path = m[1]; // /s/... 部分
const internalLink = window.location.origin + path;
const prefix = raw.slice(0, m.index).trim(); // 链接前面的描述文字
const internalText = [
prefix,
`内网链接: ${internalLink}`
].join('\n');
// 覆盖剪贴板内容
e.preventDefault();
e.clipboardData.setData('text/plain', internalText);
showToast('已替换为内网链接');
});
})();