|
1 | 1 | // ==UserScript== |
2 | 2 | // @name 蓝奏云网盘增强 |
3 | | -// @version 1.0.4 |
| 3 | +// @version 1.0.5 |
4 | 4 | // @author X.I.U |
5 | | -// @description 自动显示更多文件(文件夹末尾按钮)、自动打开分享链接(点击文件时) |
| 5 | +// @description 自动显示更多文件(文件夹末尾按钮)、自动打开分享链接(点击文件时)、自动复制分享链接(点击文件时) |
6 | 6 | // @match *://www.lanzou.com/account.php |
7 | 7 | // @match *://www.lanzou.com/u |
8 | 8 | // @match *://up.woozooo.com/u |
|
29 | 29 | } |
30 | 30 |
|
31 | 31 | var menu_open_fileSha = GM_getValue('xiu2_menu_open_fileSha'); |
32 | | - var menu_open_fileSha_ID, menu_feedBack_ID; |
| 32 | + var menu_copy_fileSha = GM_getValue('xiu2_menu_copy_fileSha'); |
| 33 | + var menu_open_fileSha_ID, menu_copy_fileSha_ID, menu_feedBack_ID; |
33 | 34 | if (menu_open_fileSha == null){menu_open_fileSha = true; GM_setValue('xiu2_menu_open_fileSha', menu_open_fileSha)}; |
| 35 | + if (menu_copy_fileSha == null){menu_copy_fileSha = true; GM_setValue('xiu2_menu_copy_fileSha', menu_copy_fileSha)}; |
34 | 36 | registerMenuCommand(); |
35 | 37 |
|
36 | 38 | // 注册脚本菜单 |
37 | 39 | function registerMenuCommand() { |
38 | | - var menu_open_fileSha_; |
| 40 | + var menu_open_fileSha_, menu_copy_fileSha_; |
39 | 41 | if (menu_feedBack_ID){ // 如果反馈菜单ID不是 null,则删除所有脚本菜单 |
40 | 42 | GM_unregisterMenuCommand(menu_open_fileSha_ID); |
| 43 | + GM_unregisterMenuCommand(menu_copy_fileSha_ID); |
41 | 44 | GM_unregisterMenuCommand(menu_feedBack_ID); |
42 | 45 | menu_open_fileSha = GM_getValue('xiu2_menu_open_fileSha'); |
| 46 | + menu_copy_fileSha = GM_getValue('xiu2_menu_copy_fileSha'); |
43 | 47 | } |
44 | 48 |
|
45 | 49 | if (menu_open_fileSha){menu_open_fileSha_ = "√";}else{menu_open_fileSha_ = "×";} |
| 50 | + if (menu_copy_fileSha){menu_copy_fileSha_ = "√";}else{menu_copy_fileSha_ = "×";} |
46 | 51 |
|
47 | | - menu_open_fileSha_ID = GM_registerMenuCommand(`[ ${menu_open_fileSha_} ] 自动打开分享链接(点击文件时)`, function(){menu_switch(menu_open_fileSha,'xiu2_menu_open_fileSha','自动打开分享链接(点击文件时)')}); |
| 52 | + menu_open_fileSha_ID = GM_registerMenuCommand(`[ ${menu_open_fileSha_} ] 自动打开分享链接(点击文件时)`, function(){menu_switch(menu_open_fileSha,'xiu2_menu_open_fileSha','自动打开分享链接')}); |
| 53 | + menu_copy_fileSha_ID = GM_registerMenuCommand(`[ ${menu_copy_fileSha_} ] 自动复制分享链接(点击文件时)`, function(){menu_switch(menu_copy_fileSha,'xiu2_menu_copy_fileSha','自动复制分享链接')}); |
48 | 54 | menu_feedBack_ID = GM_registerMenuCommand('反馈 & 建议', function () {window.GM_openInTab('https://github.com/XIU2/UserScript#xiu2userscript', {active: true,insert: true,setParent: true});}); |
49 | 55 | } |
50 | 56 |
|
|
82 | 88 | } |
83 | 89 |
|
84 | 90 |
|
85 | | - // 自动打开分享链接(点击文件时) |
| 91 | + // 分享链接相关(点击文件时) |
86 | 92 | function fileSha() { |
| 93 | + var f_sha = mainframe.document.getElementById("f_sha"); // 寻找分享链接(下载链接)信息框 |
| 94 | + if(f_sha && f_sha.style.display == "block"){ // 判断信息框是否存在且可见 |
| 95 | + fileSha_Open(); // 自动打开分享链接(点击文件时) |
| 96 | + fileSha_Copy(); // 自动复制分享链接(点击文件时) |
| 97 | + if(menu_open_fileSha || menu_copy_fileSha){ |
| 98 | + f_sha.style.display = "none"; // 隐藏分享链接(下载链接)信息框 |
| 99 | + } |
| 100 | + } |
| 101 | + } |
| 102 | + |
| 103 | + |
| 104 | + // 自动打开分享链接(点击文件时) |
| 105 | + function fileSha_Open() { |
87 | 106 | if(menu_open_fileSha){ // 脚本菜单开启时才继续 |
88 | | - var f_sha = mainframe.document.getElementById("f_sha"); // 寻找分享链接(下载链接)信息框 |
89 | | - if(f_sha && f_sha.style.display == "block"){ // 判断信息框是否存在且可见 |
90 | | - let code = mainframe.document.getElementById("code").getAttribute("title"); // 获取分享链接(下载链接) |
91 | | - if(code != ""){ // 确保分享链接(下载链接)不是空 |
92 | | - f_sha.style.display = "none"; // 隐藏分享链接(下载链接)信息框 |
93 | | - window.GM_openInTab(code, {active: true,insert: true,setParent: true}) // 打开分享链接(下载链接) |
94 | | - } |
| 107 | + let code = mainframe.document.getElementById("code").getAttribute("title"); // 获取分享链接(下载链接) |
| 108 | + if(code != ""){ // 确保分享链接(下载链接)不是空 |
| 109 | + window.GM_openInTab(code, {active: true,insert: true,setParent: true}) // 打开分享链接(下载链接) |
95 | 110 | } |
96 | 111 | } |
97 | 112 | } |
98 | 113 |
|
99 | 114 |
|
| 115 | + // 自动复制分享链接(点击文件时) |
| 116 | + function fileSha_Copy() { |
| 117 | + if(menu_copy_fileSha){ // 脚本菜单开启时才继续 |
| 118 | + let f_sha1 = mainframe.document.getElementById("f_sha1").innerText; // 获取分享链接(下载链接) |
| 119 | + if(f_sha1 != ""){ // 确保分享链接(下载链接)不是空 |
| 120 | + copyToClipboard(f_sha1); // 复制到剪切板 |
| 121 | + } |
| 122 | + } |
| 123 | + } |
| 124 | + |
| 125 | + |
| 126 | + // 复制到剪切板 |
| 127 | + function copyToClipboard(s){ |
| 128 | + if(window.clipboardData){ |
| 129 | + window.clipboardData.setData('text',s); |
| 130 | + }else{ |
| 131 | + (function(s){ |
| 132 | + document.oncopy=function(e){ |
| 133 | + e.clipboardData.setData('text',s); |
| 134 | + e.preventDefault(); |
| 135 | + document.oncopy=null; |
| 136 | + } |
| 137 | + })(s); |
| 138 | + document.execCommand('Copy'); |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + |
100 | 143 | // 定时执行(旧方法,每隔 100ms 执行一次,比较笨且浪费一丢丢性能,但优点是不会漏掉且反应更快) |
101 | 144 | //setInterval(fileMore,100); |
102 | 145 |
|
|
0 commit comments