Skip to content

Commit 2f847c7

Browse files
committed
新增 [带密码的分享链接自动输密码] 功能; 优化 脚本代码
1 parent d836f52 commit 2f847c7

1 file changed

Lines changed: 42 additions & 14 deletions

File tree

Lanzou-Enhanced.user.js

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// ==UserScript==
22
// @name 蓝奏云网盘增强
3-
// @version 1.2.6
3+
// @version 1.2.7
44
// @author X.I.U
5-
// @description 刷新不回根目录、后退返回上一级、右键文件显示菜单、自动显示更多文件、自动打开分享链接、自动复制分享链接、拖入文件自动显示上传框、输入密码后回车确认、调整描述(话说)编辑框初始大小
5+
// @description 刷新不回根目录、后退返回上一级、右键文件显示菜单、自动显示更多文件、自动打开分享链接、自动复制分享链接、带密码的分享链接自动输密码、拖入文件自动显示上传框、输入密码后回车确认、调整描述(话说)编辑框初始大小
66
// @match *://*.lanzous.com/*
77
// @match *://*.lanzoux.com/*
88
// @match *://*.lanzoui.com/*
@@ -83,19 +83,24 @@
8383
}
8484

8585

86-
if (document.getElementById("infos")) { // 分享链接文件列表页
87-
if (document.getElementById("pwdload")) { // 分享链接输入密码页
88-
enterToPass(); // 输入密码后回车确认
89-
}
90-
setTimeout(fileMoreS, 300); // 自动显示更多文件
91-
} else if (document.querySelector("iframe.ifr2")) { // 分享链接文件下载页(暂时没有这方面的功能,先空着)
92-
//console.log()
93-
} else if (document.getElementById("mainframe") || window.top.location.href.indexOf("mydisk.php?") > -1) { // 后台页
86+
if (window.top.location.pathname === '/u' || window.top.location.pathname.indexOf('account.php') > -1 || window.top.location.pathname.indexOf('mydisk.php') > -1) { // 后台页
9487
if (window.top.location.href != "https://pc.woozooo.com/mydisk.php") {
9588
window.top.location.href = "https://pc.woozooo.com/mydisk.php"
9689
}
9790
var mainframe;
9891
iframe();
92+
} else if (window.top.location.pathname.indexOf('%') > -1) { // 带密码的分享链接页面
93+
shareLinkWithPassword(); // 带密码的分享链接自动输密码
94+
} else {
95+
setTimeout(function() { // 延迟 300 毫秒(避免网页还没加载完)
96+
if (document.getElementById('infos')) { // 分享链接文件列表页
97+
if (document.getElementById('pwdload')) { // 分享链接输入密码页
98+
enterPassword(); // 自动输入密码(仅支持访问 带密码的分享链接 时)
99+
enterToPass(); // 输入密码后回车确认
100+
}
101+
fileMoreS(); // 自动显示更多文件
102+
}
103+
}, 300);
99104
}
100105

101106

@@ -117,6 +122,33 @@
117122
}
118123

119124

125+
// 带密码的分享链接自动输密码
126+
function shareLinkWithPassword() {
127+
if (location.pathname.indexOf('%E5%AF%86%E7%A0%81') > -1) {
128+
let shareLink = location.pathname.split('%')
129+
if (shareLink.length > 0) {
130+
shareLink = location.origin + shareLink[0]
131+
let password = location.pathname.replace('%E5%AF%86%E7%A0%81',':').replace(/%([A-Z]|[0-9]){2}/ig, '').split(':')
132+
if (password.length > 0) {
133+
location.replace(shareLink + '?password=' + password[password.length - 1])
134+
}
135+
}
136+
}
137+
}
138+
139+
140+
// 自动输入密码(仅支持访问 带密码的分享链接 时)
141+
function enterPassword() {
142+
if (location.search.indexOf('?password=') > -1) {
143+
let password = location.search.split('=')
144+
if (password.length > 0) {
145+
document.getElementById('pwd').value = password[password.length - 1]
146+
document.getElementById('sub').click();
147+
}
148+
}
149+
}
150+
151+
120152
// 刷新不返回根目录(F5)
121153
function refreshCorrection() {
122154
document.onkeydown = mainframe.onkeydown = function (e) {
@@ -372,10 +404,6 @@
372404
}
373405

374406

375-
// 定时执行(旧方法,每隔 100ms 执行一次,比较笨且浪费一丢丢性能,但优点是不会漏掉且反应更快)
376-
//setInterval(fileMore,100);
377-
378-
379407
// 监听 XMLHttpRequest 事件并执行(新方法,只有在产生事件时才会执行 [自动显示更多文件],平时不会执行,更优雅~)
380408
function EventXMLHttpRequest() {
381409
var _send = mainframe.XMLHttpRequest.prototype.send

0 commit comments

Comments
 (0)