Skip to content

Commit 9f475b2

Browse files
committed
新增 [自动打开分享链接(点击文件时)] 功能;优化 延迟时间(更不容易漏掉)
1 parent 32a3e02 commit 9f475b2

2 files changed

Lines changed: 71 additions & 9 deletions

File tree

Lanzou-Enhanced.user.js

Lines changed: 70 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
// ==UserScript==
22
// @name 蓝奏云网盘增强
3-
// @version 1.0.1
3+
// @version 1.0.2
44
// @author X.I.U
5-
// @description 自动显示更多文件(文件夹末尾按钮)
5+
// @description 自动显示更多文件(文件夹末尾按钮)、自动打开分享链接(点击文件时)
66
// @match https://www.lanzou.com/account.php
77
// @match https://up.woozooo.com/mydisk.php*
88
// @icon https://www.lanzou.com/favicon.ico
99
// @grant GM_xmlhttpRequest
1010
// @grant GM_registerMenuCommand
11+
// @grant GM_unregisterMenuCommand
1112
// @grant GM_openInTab
13+
// @grant GM_getValue
14+
// @grant GM_setValue
15+
// @grant GM_notification
1216
// @noframes
1317
// @license GPL-3.0 License
1418
// @run-at document-end
@@ -22,8 +26,38 @@
2226
window.top.location.href = "https://up.woozooo.com/mydisk.php"
2327
}
2428

29+
var menu_open_fileSha = GM_getValue('xiu2_menu_open_fileSha');
30+
var menu_open_fileSha_ID, menu_feedBack_ID;
31+
if (menu_open_fileSha == null){menu_open_fileSha = true; GM_setValue('xiu2_menu_open_fileSha', menu_open_fileSha)};
32+
registerMenuCommand();
33+
2534
// 注册脚本菜单
26-
GM_registerMenuCommand('反馈 & 建议', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});});
35+
function registerMenuCommand() {
36+
var menu_open_fileSha_;
37+
if (menu_feedBack_ID){ // 如果反馈菜单ID不是 null,则删除所有脚本菜单
38+
GM_unregisterMenuCommand(menu_open_fileSha_ID);
39+
GM_unregisterMenuCommand(menu_feedBack_ID);
40+
menu_open_fileSha = GM_getValue('xiu2_menu_open_fileSha');
41+
}
42+
43+
if (menu_open_fileSha){menu_open_fileSha_ = "√";}else{menu_open_fileSha_ = "×";}
44+
45+
menu_open_fileSha_ID = GM_registerMenuCommand(`[ ${menu_open_fileSha_} ] 自动打开分享链接(点击文件时)`, function(){menu_switch(menu_open_fileSha,'xiu2_menu_open_fileSha','自动打开分享链接(点击文件时)')});
46+
menu_feedBack_ID = GM_registerMenuCommand('反馈 & 建议', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});});
47+
}
48+
49+
50+
// 菜单开关
51+
function menu_switch(menu_status, Name, Tips) {
52+
if (menu_status){
53+
GM_setValue(`${Name}`, false);
54+
GM_notification(`已关闭 [${Tips}] 功能\n(刷新网页后生效)`);
55+
}else{
56+
GM_setValue(`${Name}`, true);
57+
GM_notification(`已开启 [${Tips}] 功能\n(刷新网页后生效)`);
58+
}
59+
registerMenuCommand(); // 重新注册脚本菜单
60+
};
2761

2862

2963
// 获取 iframe 框架
@@ -43,10 +77,25 @@
4377

4478
// 自动显示更多文件
4579
function fileMore() {
46-
var filemore = mainframe.document.getElementById("filemore");
47-
if(filemore && filemore.style.display != "none"){
48-
if(filemore.children[0]){
49-
filemore.children[0].click();
80+
let filemore = mainframe.document.getElementById("filemore"); // 寻找 [显示更多文件] 按钮
81+
if(filemore && filemore.style.display == "block"){ // 判断按钮是否存在且可见
82+
if(filemore.children[0]){ // 判断按钮元素下第一个元素是否存在
83+
filemore.children[0].click(); // 点击 [显示更多文件] 按钮
84+
}
85+
}
86+
}
87+
88+
89+
// 自动打开分享链接(点击文件时)
90+
function fileSha() {
91+
if(menu_open_fileSha){ // 脚本菜单开启时才继续
92+
var f_sha = mainframe.document.getElementById("f_sha"); // 寻找分享链接(下载链接)信息框
93+
if(f_sha && f_sha.style.display == "block"){ // 判断信息框是否存在且可见
94+
let f_sha1 = mainframe.document.getElementById("f_sha1").innerText; // 获取分享链接(下载链接)
95+
if(f_sha1 != ""){ // 确保分享链接(下载链接)不是空
96+
f_sha.style.display = "none"; // 隐藏分享链接(下载链接)信息框
97+
window.GM_openInTab(f_sha1, {active: true,insert: true,setParent: true}) // 打开分享链接(下载链接)
98+
}
5099
}
51100
}
52101
}
@@ -60,9 +109,22 @@
60109
function EventXMLHttpRequest() {
61110
var _send = mainframe.XMLHttpRequest.prototype.send
62111
function sendReplacement(data) {
63-
setTimeout(fileMore, 200); // 延迟执行,避免网页还没加载完
112+
setTimeout(fileMore, 300); // 自动显示更多文件
113+
setTimeout(fileSha, 300); // 自动打开分享链接(点击文件时)
64114
return _send.apply(this, arguments);
65115
}
66116
mainframe.XMLHttpRequest.prototype.send = sendReplacement;
67117
}
118+
119+
120+
/*(function (open) {
121+
mainframe.XMLHttpRequest.prototype.open = function () {
122+
this.addEventListener("readystatechange", function () {
123+
if(this.responseURL != "") {
124+
console.log(this.responseURL);
125+
}
126+
}, false);
127+
open.apply(this, arguments);
128+
};
129+
})(mainframe.XMLHttpRequest.prototype.open);*/
68130
})();

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
| **3DM论坛 美化** | 精简多余内容 | **[「安装」](https://greasyfork.org/zh-CN/scripts/413593)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Beautification.user.js)** |
2121
| **3DM论坛 增强** | 自动回复、自动无缝翻页、清理置顶帖子 | **[「安装」](https://greasyfork.org/zh-CN/scripts/412890)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Enhanced.user.js)** |
2222
| **423Down 增强 \*** | 自动无缝翻页 | **[「安装」](https://greasyfork.org/zh-CN/scripts/419215)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/423Down-Enhanced.user.js)** |
23-
| **蓝奏云网盘 增强 \*** | 自动显示更多文件(文件夹末尾按钮) | **[「安装」](https://greasyfork.org/zh-CN/scripts/419224)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Lanzou-Enhanced.user.js)** |
23+
| **蓝奏云网盘 增强 \*** | 自动显示更多文件、自动打开分享链接(点击文件时)... | **[「安装」](https://greasyfork.org/zh-CN/scripts/419224)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Lanzou-Enhanced.user.js)** |
2424
| **智友邦论坛 美化** | 精简多余内容、宽屏显示 | **[「安装」](https://greasyfork.org/zh-CN/scripts/412361)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Beautification.user.js)** |
2525
| **智友邦论坛 增强** | 自动签到、自动回复、自动无缝翻页、清理置顶帖子... | **[「安装」](https://greasyfork.org/zh-CN/scripts/412362)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Enhanced.user.js)** |
2626
| ~~_**Google 翻译 美化**_~~ | ~~_精简多余内容、修复翻译结果溢出屏幕问题_~~ | ~~_**[「安装」](https://greasyfork.org/zh-CN/scripts/413721)**_~~ | ~~_**[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/GoogleTranslate-Beautification.user.js)**_~~ |

0 commit comments

Comments
 (0)