本帖最后由 GWzrScuAQ7AhTJW 于 2025-7-14 12:23 编辑
总是有些分享的蓝奏云网址打不开,于是用ai写了一个Chrome扩展插件,分享给有需要的人。
初版:蓝奏云重定向插件,在本帖内
升级版:多域名重定向管理器(内置蓝奏云重定向)在8#
主要功能是:自动重定向蓝奏云的各种域名变体到目标域名lanzoux.com,并可根据需要,自行修改目标域名,新增、删除域名变体。
具体功能特点:- 智能域名转换:
- 将访问的蓝奏云变体域名(如lanzouv.com、lanzoub.com、lanzoui.com等)自动转换为lanzoux.com
- 保留原始URL的子域名(如www、download等)
- 保留完整的路径和查询参数
- 支持目标域名自定义,支持新增变体域名
- 全面覆盖:
- 支持所有常见的蓝奏云域名变体(v/b/i/x/y/w/t/f/g/p/q/s等)
- 处理带子域名和不带子域名的请求
- 支持所有资源类型(网页、脚本、图片等)
- 无缝体验:
- 用户访问蓝奏云链接时自动完成重定向
- 保持原始URL的结构不变(仅替换域名部分)
- 无需用户额外操作
文件结构
lanzou-redirect/
├── manifest.json
├── options.css
├── options.html
├── options.js
├── rules.json
├── service-worker.js
└── icon.png (可选)
lanzou-redirect.zip
(7.36 KB, 下载次数: 21)
安装和使用- 创建包含7个文件的文件夹
- 在 Chrome 中打开 chrome://extensions
- 启用"开发者模式"
- 点击"加载已解压的扩展程序"并选择文件夹
- 测试以下链接:
- https://www.lanzouv.com/file/123
- http://download.lanzoub.com/?id=abc
- https://lanzoui.com/share
关键的域名替换代码如下,其他文件代码可以下载附件查看。
rules.js
[JavaScript] 纯文本查看 复制代码 async function updateRedirectRules(settings) {
const oldRules = await chrome.declarativeNetRequest.getDynamicRules();
const oldRuleIds = oldRules.map(rule => rule.id);
await chrome.declarativeNetRequest.updateDynamicRules({
removeRuleIds: oldRuleIds
});
if (!settings.groups || settings.groups.length === 0) return;
const newRules = [];
let ruleCounter = 1000; // 起始ID值
settings.groups.forEach(group => {
if (!group.enabled) return;
group.sourceDomains.forEach(domain => {
const escapedDomain = domain.replace(/\./g, "\\.");
// 带子域名的规则 - 确保ID是整数
newRules.push({
id: ruleCounter++,
priority: 1,
action: {
type: 'redirect',
redirect: {
regexSubstitution: `https://\\1.${group.targetDomain}\\2`
}
},
condition: {
regexFilter: `^https?://([^.]+)\\.${escapedDomain}(.*)$`,
resourceTypes: [
'main_frame', 'sub_frame', 'script', 'xmlhttprequest',
'image', 'stylesheet', 'font', 'other'
]
}
});
// 不带子域名的规则 - 确保ID是整数
newRules.push({
id: ruleCounter++,
priority: 1,
action: {
type: 'redirect',
redirect: {
regexSubstitution: `https://${group.targetDomain}\\1`
}
},
condition: {
regexFilter: `^https?://${escapedDomain}(.*)$`,
resourceTypes: [
'main_frame', 'sub_frame', 'xmlhttprequest',
'script', 'image', 'stylesheet', 'font', 'other'
]
}
});
});
});
if (newRules.length > 0) {
await chrome.declarativeNetRequest.updateDynamicRules({
addRules: newRules
});
}
} |