一款基于 WXT 框架开发的现代化 YouTube 视频下载浏览器扩展,支持多种视频质量和音频格式,提供流畅的用户体验。
rounded-2xl 圆角和流畅动画设计规范git clone https://github.com/yourusername/youtube-downloader.git
cd youtube-downloader
npm install
# 或使用 pnpm
pnpm install
# Chrome/Edge 开发
npm run dev
# Firefox 开发
npm run dev:firefox
chrome://extensions/ (或 edge://extensions/).output/chrome-mv3 目录about:debugging#/runtime/this-firefox.output/firefox-mv2 目录中的 manifest.jsonytd.suck-dick.tech 视频处理服务youtube-downloader/ ├── entrypoints/ │ ├── youtube.content.ts # 主内容脚本 │ └── style.css # 自定义样式 ├── public/ │ └── icon/ # 扩展图标资源 ├── webfonts/ # Font Awesome 字体文件 ├── wxt.config.ts # WXT 配置文件 ├── tsconfig.json # TypeScript 配置 └── package.json # 项目依赖
| 命令 | 说明 |
|---|---|
npm run dev | 启动 Chrome 开发模式 (热重载) |
npm run dev:firefox | 启动 Firefox 开发模式 |
npm run build | 构建生产版本 (Chrome/Edge) |
npm run build:firefox | 构建 Firefox 版本 |
npm run zip | 打包为 .zip 文件用于发布 |
npm run zip:firefox | 打包 Firefox 版本 |
entrypoints/youtube.content.ts)export default defineContentScript({
matches: ['*://www.youtube.com/*'],
main() {
// 1. 检测 YouTube 页面加载
// 2. 注入下载按钮到播放器控制栏
// 3. 创建可折叠的下载选项面板
// 4. 监听用户交互事件
}
});
XMLHttpRequest 监听 progress 事件<a> 标签触发下载// 自动检测 YouTube 暗色模式
const isDarkMode = document.documentElement.hasAttribute('dark');
panel.style.backgroundColor = isDarkMode
? 'rgba(33, 33, 33, 0.95)'
: 'rgba(255, 255, 255, 0.95)';
https://ytd.suck-dick.tech/api/v1/request{
"url": "https://www.youtube.com/watch?v=VIDEO_ID",
"format": "mp4",
"quality": "1080p"
}
{
"success": true,
"download_url": "https://cdn.example.com/video.mp4",
"filename": "video_title.mp4",
"filesize": 52428800
}
// 防止 XSS 攻击的 CSP 兼容实现
if (window.trustedTypes && trustedTypes.createPolicy) {
trustedTypes.createPolicy('default', {
createHTML: (string) => string,
createScriptURL: (string) => string,
createScript: (string) => string,
});
}
eval() 和内联脚本导航到 YouTube 视频页面
https://www.youtube.com/watch?v=dQw4w9WgXcQ)定位下载按钮
选择下载选项
开始下载
┌─────────────────────────────────────┐ │ 📥 Download Panel │ ├─────────────────────────────────────┤ │ [视频] [音频] │ │ │ │ 🎥 视频质量: │ │ [8K] [4K] [2K] [1080p] │ │ [720p] [480p] [360p] │ │ │ │ ━━━━━━━━━━━ 75% ━━━━━━━━━━━ │ │ Downloading: 38.4 MB / 51.2 MB │ └─────────────────────────────────────┘
chrome://extensions/ 确认扩展已启用如果您发现 bug 或有功能建议:
**问题描述**
简要说明问题...
**复现步骤**
1. 打开 YouTube 视频...
2. 点击下载按钮...
3. 观察到错误...
**预期行为**
描述您期望发生的情况...
**环境信息**
- 浏览器: Chrome 120.0.6099.109
- 操作系统: Windows 11
- 扩展版本: 1.3
**截图**
如果适用,添加截图帮助说明问题
git clone https://github.com/yourusername/youtube-downloader.git
cd youtube-downloader
git checkout -b feature/your-feature-name
进行更改
npm run build提交代码
git add .
git commit -m "feat: add amazing feature"
git push origin feature/your-feature-name
然后在 GitHub 上创建 Pull Request
本项目采用 MIT License 开源许可证。
MIT License Copyright (c) 2025 Andy Zhang Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files...
⚠️ 重要提示
合法使用: 本扩展仅供个人学习和研究使用。请尊重内容创作者的版权。
版权合规:
免责条款:
服务可用性:
如果这个项目对您有帮助,请给我们一个 ⭐ Star!
Made with ❤️ using WXT Framework