|
1 | 1 | // ==UserScript== |
2 | 2 | // @name 蓝奏云网盘增强 |
3 | | -// @version 1.4.4 |
| 3 | +// @version 1.4.5 |
4 | 4 | // @author X.I.U |
5 | 5 | // @description 文件排序、刷新不回根目录、快捷返回上一级(右键网页空白处)、后退返回上一级、右键文件显示菜单、点击直接下载文件、点击空白进入目录、自动显示更多文件、一键复制所有分享链接、自定义分享链接域名、自动打开/复制分享链接、带密码的分享链接自动输密码、拖入文件自动显示上传框、输入密码后回车确认、调整描述(话说)编辑框初始大小 |
6 | 6 | // @include /^https:\/\/.+\.lanzou[a-z]\.com\/.*$/ |
|
716 | 716 | } |
717 | 717 | // 转换时间格式 |
718 | 718 | function parseTime(now, text) { |
| 719 | + function parseDay(time) { |
| 720 | + const days = [ |
| 721 | + { |
| 722 | + name: '前天', |
| 723 | + offset: -2, |
| 724 | + }, |
| 725 | + { |
| 726 | + name: '昨天', |
| 727 | + offset: -1, |
| 728 | + } |
| 729 | + ]; |
| 730 | + const date = new Date(now.getTime()); |
| 731 | + let index = -1; |
| 732 | + for (let i = 0; i < days.length; i++) { |
| 733 | + if (time.indexOf(days[i].name) > -1) { |
| 734 | + index = i; |
| 735 | + break; |
| 736 | + } |
| 737 | + } |
| 738 | + if (index === -1) return new Date(now.getTime()); |
| 739 | + const hourAndMinute = text.replace(days[index].name, '').split(':'); |
| 740 | + const hour = parseInt(hourAndMinute[0]); |
| 741 | + const minute = parseInt(hourAndMinute[1]); |
| 742 | + date.setDate(date.getDate() + days[index].offset); |
| 743 | + date.setHours(hour); |
| 744 | + date.setMinutes(minute); |
| 745 | + // 蓝奏云显示比较奇怪,超过24小时,未满48小时,都是昨天,并不以每天0点作为分界 |
| 746 | + if (hour * 60 + minute > now.getHours() * 60 + now.getMinutes()) { |
| 747 | + date.setDate(date.getDate() - 1); |
| 748 | + } |
| 749 | + return date; |
| 750 | + } |
719 | 751 | if (text.indexOf('秒前') > -1) { |
720 | | - return now - parseInt(text.replace('秒前', '')) * 1000; |
| 752 | + return now.getTime() - parseInt(text.replace('秒前', '')) * 1000; |
721 | 753 | } else if (text.indexOf('分钟前') > -1) { |
722 | | - return now - parseInt(text.replace('分钟前', '')) * 60 * 1000; |
| 754 | + return now.getTime() - parseInt(text.replace('分钟前', '')) * 60 * 1000; |
723 | 755 | } else if (text.indexOf('小时前') > -1) { |
724 | | - return now - parseInt(text.replace('小时前', '')) * 60 * 60 * 1000; |
| 756 | + return now.getTime() - parseInt(text.replace('小时前', '')) * 60 * 60 * 1000; |
| 757 | + } else if (text.indexOf('昨天') > -1 || text.indexOf('前天') > -1) { |
| 758 | + return parseDay(text).getTime(); |
725 | 759 | } else if (text.indexOf('天前') > -1) { |
726 | | - return now - parseInt(text.replace('天前', '')) * 24 * 60 * 60 * 1000; // 我不知道有没有以下几种情况,暂时先写上 |
727 | | - } else if (text.indexOf('月前') > -1) { |
728 | | - return now - parseInt(text.replace('月前', '')) * 30 * 24 * 60 * 60 * 1000; |
| 760 | + return now.getTime() - parseInt(text.replace('天前', '')) * 24 * 60 * 60 * 1000; |
| 761 | + } else if (text.indexOf('月前') > -1) { // 我不知道有没有以下几种情况,暂时先写上 |
| 762 | + return now.getTime() - parseInt(text.replace('月前', '')) * 30 * 24 * 60 * 60 * 1000; |
729 | 763 | } else if (text.indexOf('年前') > -1) { |
730 | | - return now - parseInt(text.replace('年前', '')) * 365 * 24 * 60 * 60 * 1000; |
| 764 | + return now.getTime() - parseInt(text.replace('年前', '')) * 365 * 24 * 60 * 60 * 1000; |
731 | 765 | } |
732 | 766 | return Date.parse(text); |
733 | 767 | } |
|
0 commit comments