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
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 框架
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 }
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} ) ( ) ;
0 commit comments