|
1 | 1 | // ==UserScript== |
2 | 2 | // @name 蓝奏云网盘增强 |
3 | | -// @version 1.1.7 |
| 3 | +// @version 1.2.0 |
4 | 4 | // @author X.I.U |
5 | | -// @description 刷新不返回根目录、右键文件显示菜单、自动显示更多文件、自动打开分享链接、自动复制分享链接、调整描述(话说)编辑框初始大小、拖入文件自动显示上传框 |
| 5 | +// @description 刷新不回根目录、后退返回上一级、右键文件显示菜单、自动显示更多文件、自动打开分享链接、自动复制分享链接、调整描述(话说)编辑框初始大小、拖入文件自动显示上传框 |
6 | 6 | // @match *://*.lanzous.com/* |
7 | 7 | // @match *://*.lanzoux.com/* |
8 | 8 | // @match *://*.lanzoui.com/* |
|
33 | 33 | menu_refreshCorrection = GM_getValue('xiu2_menu_refreshCorrection'), |
34 | 34 | menu_rightClickMenu = GM_getValue('xiu2_menu_rightClickMenu'), |
35 | 35 | menu_folderDescdesMenu = GM_getValue('xiu2_menu_folderDescdesMenu'); |
36 | | - var menu_open_fileSha_ID, menu_copy_fileSha_ID, menu_refreshCorrection_ID, menu_rightClickMenu_ID, menu_folderDescdesMenu_ID, menu_feedBack_ID; |
| 36 | + var menu_open_fileSha_ID, menu_copy_fileSha_ID, menu_refreshCorrection_ID, menu_rightClickMenu_ID, menu_folderDescdesMenu_ID, menu_feedBack_ID, lastFolderID; |
37 | 37 | if (menu_open_fileSha == null){menu_open_fileSha = true; GM_setValue('xiu2_menu_open_fileSha', menu_open_fileSha)}; |
38 | 38 | if (menu_copy_fileSha == null){menu_copy_fileSha = true; GM_setValue('xiu2_menu_copy_fileSha', menu_copy_fileSha)}; |
39 | 39 | if (menu_refreshCorrection == null){menu_refreshCorrection = true; GM_setValue('xiu2_menu_refreshCorrection', menu_refreshCorrection)}; |
|
107 | 107 | // 获取 iframe 框架 |
108 | 108 | function iframe() { |
109 | 109 | mainframe = document.getElementById("mainframe"); |
110 | | - if(mainframe){ // 只有找到 iframe 框架时才会继续运行脚本 |
| 110 | + if(mainframe){ // 只有找到 iframe 框架时才会继续运行脚本 |
111 | 111 | mainframe = mainframe.contentWindow; |
112 | 112 | if(menu_refreshCorrection){ |
113 | | - refreshCorrection(); // 刷新不返回根目录(F5) |
| 113 | + refreshCorrection(); // 刷新不返回根目录(F5) |
114 | 114 | } |
115 | 115 | setTimeout(folderDescdes, 200); // 调整话说编辑框初始大小 |
116 | | - EventXMLHttpRequest(); // 监听 XMLHttpRequest 事件并执行 [自动显示更多文件] |
| 116 | + fobiddenBack(); // 禁止浏览器返回(并绑定新的返回事件) |
| 117 | + EventXMLHttpRequest(); // 监听 XMLHttpRequest 事件并执行 [自动显示更多文件] |
117 | 118 |
|
118 | | - dragEnter(); // 拖入文件自动显示上传框 |
| 119 | + dragEnter(); // 拖入文件自动显示上传框 |
119 | 120 | } |
120 | 121 | } |
121 | 122 |
|
|
289 | 290 | } |
290 | 291 |
|
291 | 292 |
|
| 293 | + // 禁止浏览器返回(并绑定新的返回事件) |
| 294 | + function fobiddenBack() { |
| 295 | + history.pushState(null, null, document.URL); |
| 296 | + window.addEventListener('popstate',backEvent) |
| 297 | + } |
| 298 | + |
| 299 | + |
| 300 | + // 允许浏览器返回 |
| 301 | + function enableBack() { |
| 302 | + history.go(-1); |
| 303 | + window.removeEventListener('popstate',backEvent) |
| 304 | + } |
| 305 | + |
| 306 | + |
| 307 | + // 浏览器后退事件函数 |
| 308 | + function backEvent() { |
| 309 | + if(lastFolderID) { |
| 310 | + mainframe.folder(lastFolderID); |
| 311 | + } |
| 312 | + history.pushState(null, null, document.URL); |
| 313 | + } |
| 314 | + |
| 315 | + |
| 316 | + // 获取上个文件夹 ID(用于浏览器后退事件) |
| 317 | + function getLastFolderID() { |
| 318 | + lastFolderID = null |
| 319 | + let f_tpspan = mainframe.document.querySelectorAll("span.f_tpspan"); |
| 320 | + if(f_tpspan.length > 1) { |
| 321 | + lastFolderID = /-?\d+/.exec(f_tpspan[f_tpspan.length - 2].getAttribute("onclick"))[0]; |
| 322 | + } |
| 323 | + } |
| 324 | + |
| 325 | + |
292 | 326 | // 定时执行(旧方法,每隔 100ms 执行一次,比较笨且浪费一丢丢性能,但优点是不会漏掉且反应更快) |
293 | 327 | //setInterval(fileMore,100); |
294 | 328 |
|
|
300 | 334 | setTimeout(fileMore, 200); // 自动显示更多文件 |
301 | 335 | setTimeout(fileSha, 200); // 自动打开分享链接(点击文件时) |
302 | 336 | setTimeout(rightClickMenu, 500); // 右键文件显示菜单 |
| 337 | + setTimeout(getLastFolderID, 200); // 获取上个文件夹 ID(用于浏览器后退事件) |
303 | 338 | return _send.apply(this, arguments); |
304 | 339 | } |
305 | 340 | mainframe.XMLHttpRequest.prototype.send = sendReplacement; |
|
0 commit comments