Closed ivysrono closed 5 months ago
其实我感觉用油猴写脚本更加通用一些,反正都是浏览器往http服务器发送下载信息,而油猴插件可以玩出花额。
出个规范,我可以接受。
其实我感觉用油猴写脚本更加通用一些,反正都是浏览器往http服务器发送下载信息,而油猴插件可以玩出花额。
火狐的包打出来了,只是没有上架市场,在release页面可下载
// ==UserScript==
// @name Download Link Capturer
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Capture user clicks on download links
// @author Your name
// @match https://*
// @grant none
// ==/UserScript==
(function () {
"use strict";
// 获取所有下载链接
const downloadLinks = document.querySelectorAll('a[href$=".pdf"], a[href$=".zip"], a[href$=".exe"]'); // 替换为您要捕获的文件类型
// 为每个下载链接添加点击事件监听器
downloadLinks.forEach((link) => {
link.addEventListener("click", function (event) {
// 阻止默认行为,以便执行自定义操作
event.preventDefault();
// 获取下载链接
const downloadUrl = this.getAttribute("href");
// 执行您想要的操作,比如发送下载链接到服务器或者执行其他逻辑
console.log("User clicked on download link: " + downloadUrl);
// 如果需要继续下载文件,可以使用以下代码
// window.location.href = downloadUrl;
// 使用油猴接口通知Gopeed创建下载任务
GM.xmlHttpRequest({
method: "POST",
url: "http://127.0.0.1:8088/api/v1/tasks",
data: `{
"req": {
"url": "https://example.com/file.mp4"
},
"opt": {
"name": "string",
"path": "string",
"selectFiles": [
0
],
"extra": {
"connections": 32
}
}
}`,
onload: (res) => {
console.log("请求成功");
},
});
});
});
})();
差不多类似这种吧。。反正我有的网站有特殊下载需求,随便写个油猴脚本就行。, 只是想要写的更通用就有点难度了。
貌似油猴不太好处理那种没有在元素里面带下载地址的情况,这种情况,用浏览器插件会轻松很多。
@jan-bar 油猴和浏览器扩展都可以的,反正都是围绕着Gopeed API来开展生态
希望可以上架Edge商店,下载更新会更方便一些
希望可以上架Edge商店,下载更新会更方便一些
已经提交审核了
firefox已经过审了,edge被拒了再重审一次
@jan-bar 油猴和浏览器扩展都可以的,反正都是围绕着Gopeed API来开展生态
后续版本能否加个接管设置?现在所有的下载都接管,有时候备份个油猴脚本数据就几K大小也接管,问题还下不动😂
既然已经支持Chrome扩展,还请支持Firefox/Edge等其他浏览器。