mirror of
https://github.com/XIU2/UserScript.git
synced 2026-10-07 15:54:20 +00:00
新增 [点击直接下载文件] 功能
This commit is contained in:
+38
-3
@@ -1,8 +1,8 @@
|
||||
// ==UserScript==
|
||||
// @name 蓝奏云网盘增强
|
||||
// @version 1.3.4
|
||||
// @version 1.3.5
|
||||
// @author X.I.U
|
||||
// @description 刷新不回根目录、后退返回上一级、右键文件显示菜单、自动显示更多文件、自定义分享链接域名、自动打开/复制分享链接、带密码的分享链接自动输密码、拖入文件自动显示上传框、输入密码后回车确认、调整描述(话说)编辑框初始大小
|
||||
// @description 刷新不回根目录、后退返回上一级、右键文件显示菜单、点击直接下载文件、自动显示更多文件、自定义分享链接域名、自动打开/复制分享链接、带密码的分享链接自动输密码、拖入文件自动显示上传框、输入密码后回车确认、调整描述(话说)编辑框初始大小
|
||||
// @match *://*.lanzous.com/*
|
||||
// @match *://*.lanzoux.com/*
|
||||
// @match *://*.lanzoui.com/*
|
||||
@@ -40,6 +40,7 @@
|
||||
['menu_copy_fileSha', '自动复制分享链接', '自动复制分享链接', true],
|
||||
['menu_refreshCorrection', '刷新不返回根目录', '刷新不返回根目录', true],
|
||||
['menu_rightClickMenu', '右键文件显示菜单', '右键文件显示菜单', true],
|
||||
['menu_directDownload', '点击直接下载文件', '点击直接下载文件', true],
|
||||
['menu_folderDescdesMenu', '调整描述(话说)编辑框大小', '调整描述(话说)编辑框大小', true]
|
||||
], menu_ID = [], lastFolderID;
|
||||
for (let i=0;i<menu_ALL.length;i++){ // 如果读取到的值为 null 就写入默认值
|
||||
@@ -113,8 +114,10 @@
|
||||
enterToPass(); // 输入密码后回车确认
|
||||
}
|
||||
fileMoreS(); // 自动显示更多文件
|
||||
directDownload(); // 点击直接下载文件(分享链接列表页)
|
||||
}
|
||||
}, 300);
|
||||
directDownload_(); // 点击直接下载文件(分享链接列表页)
|
||||
}
|
||||
|
||||
|
||||
@@ -252,6 +255,36 @@
|
||||
}
|
||||
|
||||
|
||||
// 点击直接下载文件(分享链接列表页)
|
||||
function directDownload() {
|
||||
if (!menu_value('menu_directDownload')) return
|
||||
if (document.getElementById('infos')) {
|
||||
document.getElementById('infos').addEventListener('click', function(e) {
|
||||
if (e.target.tagName === 'A') {
|
||||
e.preventDefault(); // 阻止默认打开链接事件
|
||||
GM_openInTab(e.target.href + '#download', {active: false, insert: true, setParent: true}); // 后台打开
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
// 点击下载按钮
|
||||
function directDownload_() {
|
||||
if (!menu_value('menu_directDownload')) return
|
||||
if (location.hash != '#download') return
|
||||
let iframe = document.querySelector('iframe.ifr2');
|
||||
if (iframe) { // 只有找到 iframe 框架时才会继续运行脚本
|
||||
iframe = iframe.contentWindow;
|
||||
let timer = setInterval(function(){
|
||||
if (iframe.document.querySelector('#go a[href]')) {
|
||||
GM_openInTab(iframe.document.querySelector('#go a[href]').href, {active: false, insert: true, setParent: false}); // 后台打开
|
||||
window.top.close(); // 关闭该后台标签页
|
||||
clearInterval(timer);
|
||||
}
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 滚动条事件
|
||||
function windowScroll(fn1) {
|
||||
var beforeScrollTop = document.documentElement.scrollTop,
|
||||
@@ -317,6 +350,8 @@
|
||||
if (menu_value('menu_open_fileSha')) {f_sha.style.display = 'none';GM_openInTab(f_sha1.textContent, {active: true,insert: true,setParent: true});}
|
||||
// 复制分享链接(并已复制的提示信息)
|
||||
if (menu_value('menu_copy_fileSha')) {f_sha.style.display = 'none';GM_setClipboard(f_sha1.textContent, 'text');GM_notification({text: '已复制分享链接~', timeout: 2000});}
|
||||
// 直接下载文件
|
||||
if (menu_value('menu_directDownload')) {f_sha.style.display = 'none';GM_openInTab(f_sha1.textContent + '#download', {active: false,insert: true,setParent: true});}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -338,7 +373,7 @@
|
||||
// 隐藏分享链接窗口(这样自动打开/复制分享链接时,不会一闪而过)
|
||||
function hideSha(){
|
||||
if (menu_value('menu_open_fileSha') || menu_value('menu_copy_fileSha')) { // [自动复制分享链接] 或 [自动打开分享链接] 任意一个功能开启时才继续
|
||||
mainframe.document.head.appendChild(document.createElement('style')).textContent = '#f_sha {display: none !important;}';
|
||||
mainframe.document.lastElementChild.appendChild(document.createElement('style')).textContent = '#f_sha {display: none !important;}';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user