新增 [自动打开分享链接(点击文件时)] 功能;优化 延迟时间(更不容易漏掉)

This commit is contained in:
xiu2
2020-12-31 12:47:24 +08:00
parent 32a3e025ff
commit 9f475b2f98
2 changed files with 71 additions and 9 deletions
+70 -8
View File
@@ -1,14 +1,18 @@
// ==UserScript==
// @name 蓝奏云网盘增强
// @version 1.0.1
// @version 1.0.2
// @author X.I.U
// @description 自动显示更多文件(文件夹末尾按钮)
// @description 自动显示更多文件(文件夹末尾按钮)、自动打开分享链接(点击文件时)
// @match https://www.lanzou.com/account.php
// @match https://up.woozooo.com/mydisk.php*
// @icon https://www.lanzou.com/favicon.ico
// @grant GM_xmlhttpRequest
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_openInTab
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_notification
// @noframes
// @license GPL-3.0 License
// @run-at document-end
@@ -22,8 +26,38 @@
window.top.location.href = "https://up.woozooo.com/mydisk.php"
}
var menu_open_fileSha = GM_getValue('xiu2_menu_open_fileSha');
var menu_open_fileSha_ID, menu_feedBack_ID;
if (menu_open_fileSha == null){menu_open_fileSha = true; GM_setValue('xiu2_menu_open_fileSha', menu_open_fileSha)};
registerMenuCommand();
// 注册脚本菜单
GM_registerMenuCommand('反馈 & 建议', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});});
function registerMenuCommand() {
var menu_open_fileSha_;
if (menu_feedBack_ID){ // 如果反馈菜单ID不是 null,则删除所有脚本菜单
GM_unregisterMenuCommand(menu_open_fileSha_ID);
GM_unregisterMenuCommand(menu_feedBack_ID);
menu_open_fileSha = GM_getValue('xiu2_menu_open_fileSha');
}
if (menu_open_fileSha){menu_open_fileSha_ = "√";}else{menu_open_fileSha_ = "×";}
menu_open_fileSha_ID = GM_registerMenuCommand(`[ ${menu_open_fileSha_} ] 自动打开分享链接(点击文件时)`, function(){menu_switch(menu_open_fileSha,'xiu2_menu_open_fileSha','自动打开分享链接(点击文件时)')});
menu_feedBack_ID = GM_registerMenuCommand('反馈 & 建议', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});});
}
// 菜单开关
function menu_switch(menu_status, Name, Tips) {
if (menu_status){
GM_setValue(`${Name}`, false);
GM_notification(`已关闭 [${Tips}] 功能\n(刷新网页后生效)`);
}else{
GM_setValue(`${Name}`, true);
GM_notification(`已开启 [${Tips}] 功能\n(刷新网页后生效)`);
}
registerMenuCommand(); // 重新注册脚本菜单
};
// 获取 iframe 框架
@@ -43,10 +77,25 @@
// 自动显示更多文件
function fileMore() {
var filemore = mainframe.document.getElementById("filemore");
if(filemore && filemore.style.display != "none"){
if(filemore.children[0]){
filemore.children[0].click();
let filemore = mainframe.document.getElementById("filemore"); // 寻找 [显示更多文件] 按钮
if(filemore && filemore.style.display == "block"){ // 判断按钮是否存在且可见
if(filemore.children[0]){ // 判断按钮元素下第一个元素是否存在
filemore.children[0].click(); // 点击 [显示更多文件] 按钮
}
}
}
// 自动打开分享链接(点击文件时)
function fileSha() {
if(menu_open_fileSha){ // 脚本菜单开启时才继续
var f_sha = mainframe.document.getElementById("f_sha"); // 寻找分享链接(下载链接)信息框
if(f_sha && f_sha.style.display == "block"){ // 判断信息框是否存在且可见
let f_sha1 = mainframe.document.getElementById("f_sha1").innerText; // 获取分享链接(下载链接)
if(f_sha1 != ""){ // 确保分享链接(下载链接)不是空
f_sha.style.display = "none"; // 隐藏分享链接(下载链接)信息框
window.GM_openInTab(f_sha1, {active: true,insert: true,setParent: true}) // 打开分享链接(下载链接)
}
}
}
}
@@ -60,9 +109,22 @@
function EventXMLHttpRequest() {
var _send = mainframe.XMLHttpRequest.prototype.send
function sendReplacement(data) {
setTimeout(fileMore, 200); // 延迟执行,避免网页还没加载完
setTimeout(fileMore, 300); // 自动显示更多文件
setTimeout(fileSha, 300); // 自动打开分享链接(点击文件时)
return _send.apply(this, arguments);
}
mainframe.XMLHttpRequest.prototype.send = sendReplacement;
}
/*(function (open) {
mainframe.XMLHttpRequest.prototype.open = function () {
this.addEventListener("readystatechange", function () {
if(this.responseURL != "") {
console.log(this.responseURL);
}
}, false);
open.apply(this, arguments);
};
})(mainframe.XMLHttpRequest.prototype.open);*/
})();
+1 -1
View File
@@ -20,7 +20,7 @@
| **3DM论坛 美化** | 精简多余内容 | **[「安装」](https://greasyfork.org/zh-CN/scripts/413593)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Beautification.user.js)** |
| **3DM论坛 增强** | 自动回复、自动无缝翻页、清理置顶帖子 | **[「安装」](https://greasyfork.org/zh-CN/scripts/412890)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/3dm-Enhanced.user.js)** |
| **423Down 增强 \*** | 自动无缝翻页 | **[「安装」](https://greasyfork.org/zh-CN/scripts/419215)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/423Down-Enhanced.user.js)** |
| **蓝奏云网盘 增强 \*** | 自动显示更多文件(文件夹末尾按钮) | **[「安装」](https://greasyfork.org/zh-CN/scripts/419224)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Lanzou-Enhanced.user.js)** |
| **蓝奏云网盘 增强 \*** | 自动显示更多文件、自动打开分享链接(点击文件时)... | **[「安装」](https://greasyfork.org/zh-CN/scripts/419224)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Lanzou-Enhanced.user.js)** |
| **智友邦论坛 美化** | 精简多余内容、宽屏显示 | **[「安装」](https://greasyfork.org/zh-CN/scripts/412361)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Beautification.user.js)** |
| **智友邦论坛 增强** | 自动签到、自动回复、自动无缝翻页、清理置顶帖子... | **[「安装」](https://greasyfork.org/zh-CN/scripts/412362)** | **[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/Zhiyoo-Enhanced.user.js)** |
| ~~_**Google 翻译 美化**_~~ | ~~_精简多余内容、修复翻译结果溢出屏幕问题_~~ | ~~_**[「安装」](https://greasyfork.org/zh-CN/scripts/413721)**_~~ | ~~_**[「安装」](https://cdn.jsdelivr.net/gh/XIU2/UserScript@master/GoogleTranslate-Beautification.user.js)**_~~ |