├── media
├── 01.jpg
├── 02.jpg
├── 03.jpg
├── error.png
├── info.png
└── success.png
├── screenshots
├── fail.png
├── menu.png
├── newUI.png
├── order.png
├── parts.png
├── search.png
├── success.png
├── category.png
└── half-success.png
├── README.md
├── LICENSE
└── bilibili-favorites-fix-cerenkov-mod.js
/media/01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/media/01.jpg
--------------------------------------------------------------------------------
/media/02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/media/02.jpg
--------------------------------------------------------------------------------
/media/03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/media/03.jpg
--------------------------------------------------------------------------------
/media/error.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/media/error.png
--------------------------------------------------------------------------------
/media/info.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/media/info.png
--------------------------------------------------------------------------------
/media/success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/media/success.png
--------------------------------------------------------------------------------
/screenshots/fail.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/screenshots/fail.png
--------------------------------------------------------------------------------
/screenshots/menu.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/screenshots/menu.png
--------------------------------------------------------------------------------
/screenshots/newUI.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/screenshots/newUI.png
--------------------------------------------------------------------------------
/screenshots/order.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/screenshots/order.png
--------------------------------------------------------------------------------
/screenshots/parts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/screenshots/parts.png
--------------------------------------------------------------------------------
/screenshots/search.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/screenshots/search.png
--------------------------------------------------------------------------------
/screenshots/success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/screenshots/success.png
--------------------------------------------------------------------------------
/screenshots/category.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/screenshots/category.png
--------------------------------------------------------------------------------
/screenshots/half-success.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/crnkv/bilibili-favorites-fix-cerenkov-mod/HEAD/screenshots/half-success.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 哔哩哔哩(B站|Bilibili)收藏夹Fix (cerenkov修改版)
2 |
3 | ---
4 |
5 | > 篡改猴(Tampermonkey)脚本,用于修复B站失效收藏、以及被up主隐藏(“仅自己可见”)的视频。
6 |
7 | ## 代码托管
8 |
9 | [Greasyfork页面](https://greasyfork.org/zh-CN/scripts/489224)
10 |
11 | [GitHub仓库](https://github.com/crnkv/bilibili-favorites-fix-cerenkov-mod)
12 |
13 |
14 | ## Chrome 系浏览器注意
15 |
16 | 由于其 Manifest V3 更新的要求,必须[启用开发者模式/开发人员模式](https://www.tampermonkey.net/faq.php#Q209)才能正常运行篡改猴(Tampermonkey)扩展,影响范围 Chrome / Edge
17 |
18 |
19 | ## 功能
20 |
21 | - **从 biliplus、 jijidown、 xbeibeix、以及 B站官方非鉴权API、 B站官方鉴权API 共五个渠道获取失效视频的信息进行修复,如果还是查不到那就没办法了**
22 | - **标题**:先查询第三方网站的信息缓存,如果没有,那么就查询 B站非鉴权API(只能查公开收藏夹)里的分P信息,如果只有1P,合理推测其标题(视频文件投稿上传时的标题)就是视频标题
23 | - **如果私密收藏夹中的失效视频依然未能恢复(查不到标题),请尝试临时更改成公开收藏夹再试一次,等脚本将查到的信息进行本地缓存了再改回私密即可**
24 | - **封面**:按顺序查询第三方网站的信息缓存,但即便有返回结果,如果返回的图片链接已失效(按照url是否包含“bfs/archive”字段判断),也会继续再查询下一家第三方网站
25 | - **UP主**:如果 B站API 返回的 UP主名称是“账号已注销”,那么就用从第三方网站查到的账号名替换(只是第三方网站缓存时的账号名,不保证能获取到UP主在注销前最后改的名字)
26 | - **简介**:从 B站非鉴权API(只能查公开收藏夹)和 B站鉴权API(能查私密收藏夹)获取,100% 恢复
27 | - **分P标题**:通常从 B站非鉴权API(只能查公开收藏夹)获取,但有时返回的数据残缺,则会用 biliplus 的细化 API 再查询一次
28 | - **恢复被隐藏的视频(由于被该UP主设置为“仅自己可见”),让收藏夹不再“缺一角”**
29 | - 由于该信息只能从 B站非鉴权API 获取,所以只能恢复公开收藏夹中的隐藏视频,如果想查私密收藏夹请先临时更改成公开
30 | - 鼠标悬停时,会弹出浮块展示AV、BV号、UP主、简介、分区、时长、发布、收藏时间、分P标题、收藏数、弹幕数、失效原因等信息
31 | - **点击视频封面可以复制全部稿件信息到剪贴板**
32 | - 如果缓存信息来自 biliplus、 jijidown 或 xbeibeix ,点击视频标题可以跳转过去
33 | - 点击视频收藏右下角功能菜单,可以复制AV、BV号、稿件信息、导出/导入缓存、查看封面图片、跳转UP主空间(B站新UI界面中点击UP名字也可跳转空间)
34 | - 由于B站新界面是动态生成操作菜单,所以鼠标要多等0.5秒,才能保证将新菜单项添加到操作菜单上
35 | - 脚本查询过的结果会本地缓存起来,储存在篡改猴(Tampermonkey)中,已查询过的视频无需再次查询,关闭浏览器也不丢失,并且可按需导出/导入,以便另作备份
36 | - 如果想清空本地缓存,只需在菜单询问“是否导出”时选择取消,在询问“粘贴导入”时输入“ `{}` ”确定即可
37 | - **导入是覆盖性的**,即把输入的内容完全替换此前的整个本地缓存
38 | - 如果不想覆盖、想增量导入,可以在前面加一个加号“ `+` ”,如“ `+{"10086": {......}, "114514": {......}}` ”,便仅仅导入 avid 10086 和 114514 两条视频的缓存
39 | - 用增量导入可以针对性地覆盖或清除特定视频的缓存,如“ `+{"10086": {}}` ”,便使得 avid 10086 的视频本地缓存被空数据覆盖,而不影响其他
40 | - 如果输入错误格式的字符串,有可能会导入成功,但脚本运行出错
41 | - 即使更改排序方式、更改限定分区,以及在当前/全部收藏夹中搜索,脚本都能正常工作了
42 | - 在全部收藏夹中搜索时,可能有些视频实际位于私密收藏夹中,所以假如它同时也是被隐藏(“仅自己可见”)视频,便无法恢复,即搜索结果仍有可能会“缺一角”
43 | - 在B站旧界面中,鼠标悬停时,封面之上会展示播放、收藏、UP主、投稿四项信息(B站新界面已不再有这个)
44 | - 此功能仅为展示网页上被隐藏起来的内容,B站网页(旧界面)本来就有
45 |
46 |
47 | ## 声明
48 |
49 | 代码 fork 自 [Mr-Po/bilibili-favorites-fix](https://github.com/Mr-Po/bilibili-favorites-fix) ( Greasyfork 脚本[哔哩哔哩(B站|Bilibili)收藏夹Fix](https://greasyfork.org/zh-CN/scripts/383143) v1.2.1 ),因为该脚本在 2023 年 11 月或更早前就有小部分功能失效需要更新修复。[历史讨论](https://greasyfork.org/zh-CN/scripts/383143/discussions/214367)
50 |
51 | 本脚本的核心功能依赖于第三方网站 biliplus.com jijidown.com xbeibeix.com 的信息缓存,非常感谢 biliplus jijidown xbeibeix 长久以来的付出。
52 |
53 |
54 | ## 类似脚本
55 |
56 | 友情链接(?):[哔哩哔哩(B站|Bilibili)收藏夹Fix (备份视频信息)](https://greasyfork.org/zh-CN/scripts/521668-bilibili-favlist-backup)
57 |
58 |
59 | ## 画面展示
60 |
61 | 脚本更新至 v1.4.4 而展示截图暂未更新,望见谅
62 |
63 | - **例:成功修复标题、封面及简介信息**
64 |
65 | 
66 |
67 | - **例:B站新界面,与旧界面有些许差异**
68 |
69 | 
70 |
71 | - **例:成功修复标题,但封面失败,因为查出来的图片网址已不可访问**
72 |
73 | 
74 |
75 | - **例:查不到标题/封面信息,只有简介信息等可以展示**
76 |
77 | 
78 |
79 | - **例:当不止一个分P时,展示子P标题(仅当标题/封面修复成功时才能获取到该信息)**
80 |
81 | 
82 |
83 | - **例:点击右下角操作菜单,可以复制AV、BV号、稿件信息、跳转UP主空间、切换简化/深度查询、导出/导入缓存**
84 |
85 | 
86 |
87 | - **例:更改排序方式,仍可正常工作**
88 |
89 | 
90 |
91 | - **例:更改限定分区,仍可正常工作**
92 |
93 | 
94 |
95 | - **例:在当前/全部收藏夹中搜索,搜索结果页仍可正常工作**
96 |
97 | 
98 |
99 |
100 | ## Changelog
101 |
102 | ### v1.4.4 - 2025.03.20
103 | - 修复
104 | - 适配B站新UI界面在宽屏(超过1760px)时的布局(6乘6)
105 |
106 | ### v1.4.3 - 2025.03.20
107 | - 新增
108 | - 加入在 xbeibeix.com 查询的功能
109 | - 优化
110 | - jijidown 查询返回“请求过快”时,从自动延时重试改成手动点击重试,合理减轻服务器负担,并复用重试函数
111 | - 优化 recoverHiddenItems() 中调用 startBiliplusQuery() 的方式
112 | - 优化代码可读性,优化用户互动提示
113 |
114 | ### v1.4.2 - 2025.03.17
115 | - 修复
116 | - 弃用 jQuery.data() ,规范化 jQuery.on("click") ,以阻止网页更新时内存泄漏
117 | - 变更
118 | - 简化功能菜单的操作体验,油猴的 GM_notification 通知似乎有点太拖了,整简单点
119 |
120 | ### v1.4.1 - 2025.03.17
121 | - 修复
122 | - 修复因网络故障中断时,视频缓存仍未建立导致的对象访问错误( queryFailed 函数)
123 | - 补上获取默认收藏夹 fid 时应有的 mid
124 | - 修复在全部收藏夹中搜索时调用API不相符的问题,使得搜索结果页面能正确地修复失效视频,但是由于B站两个API返回的搜索结果顺序不一致,所以依然无法保证完整恢复隐藏视频,如果搜索结果第一页还是缺几格,那么往后翻第二页说不定就会出现所缺的那几个隐藏视频,只是由于API获取信息不全导致它被挪到了后一页
125 | - 新增
126 | - 对于up主名称是“账号已注销”的,将查询得到的up主名字替换上去并缓存起来
127 | - 增量导入功能:在使用导入功能时,在字符串`{...}`的开头加上`+`号前缀,则将其内容以视频avid为单位增量填入缓存中,而不是把整个 JSON 对象替换到缓存
128 | - 优化
129 | - 通过并列 img 元素,使得当查询 biliplus 得到的封面图链接失效、而 first_frame 链接仍有效的时候,浏览器自动隐藏失效的封面图、展示可用的 first_frame 图,而当点击“查看封面图片”时,会将封面图和首帧截图一起打开
130 | - 优化代码,减少逻辑冗余,增加可读性
131 | - 变更
132 | - 点击封面的效果改为复制稿件信息
133 |
134 | ### v1.4.0 - 2025.03.14
135 | - 修复
136 | - 当 url 不含 fid 且网页源码亦不含默认收藏夹的 fid 时,查询简介等信息会出错,需要另发网络请求才能获取默认收藏夹的 fid
137 | - 新增
138 | - 对于被隐藏的视频(表现为收藏夹缺了一格,而不是显示“已失效视频”),亦即被up主设为“仅自己可见”的视频(而不是被B站删除/退回),如果是在公开收藏夹,现在能够恢复了,如果是私密收藏夹就请手动改成公开收藏夹才能恢复
139 | - 使用 Tampermonkey 的存储来保存缓存,不再需要在刷新/关闭标签页前手动导出缓存保存查询进度
140 | - 除了在 biliplus.com 查询信息以外,还加入在 jijidown.com 查询失效视频信息,从而能找回更多的标题/封面信息
141 | - 新增操作菜单:新标签页查看封面图片、查看视频首帧截图、清除本视频的缓存信息
142 | - 优化
143 | - 鼠标悬停浮块增加点赞数、投币数、回复数、视频分区信息
144 | - 混合使用B站的新API和旧API:对于公开收藏夹将优先查询旧API、获取潜在的藏在分P内的视频标题、并保存在缓存中,同时将分P第一P标题视作视频标题候选,从而能找回更多视频的标题。(对于私密收藏夹则查询新API,和之前一样)
145 | - 对于B站API和 biliplus 都返回信息的情况,完善取舍逻辑,refactor 处理流程,进一步大幅度简化和重写 biliplus 的查询流程,根治以前经常“请求过快”的问题
146 | - 即便查询 biliplus 返回了信息,但返回的封面图网址失效,那仍然会再查询 jijidown ,判断并获取真正有用的封面图
147 | - 用 MutationObserver 按需执行来取代以前的 setInterval 定时循环执行
148 | - 变更
149 | - 由于B站新UI的渲染bug已被修复,所以移除临时补丁 stripTitleFirefox
150 | - 由于重写 biliplus 和 jijidown 的查询流程,不再保留之前的(没多大作用的)简化查询/深度查询
151 |
152 | ### v1.3.1 - 2024.12.16
153 | - 修复
154 | - 360极速浏览器会获取不到 GM_info.userAgentData.brands
155 |
156 | ### v1.3.0 - 2024.12.10
157 | - 修复
158 | - 多余的网址正则匹配导致脚本有时不运行
159 | - 完善网络查询过程中的意外错误处理,让脚本不再卡在Loading...上,且控制台和视频标题都提供更详细的错误信息
160 | - B站新界面在Firefox上的渲染有毛病,视频标题行太长的话,鼠标悬停时菜单按钮不出现,为保证菜单按钮在失效视频上出现只好临时应对B站新界面的bug,等B站修好再移除补丁
161 | - 新增
162 | - 查询结果缓存,在收藏界翻页、切换收藏夹时,已查询过的视频无需再次查询,并且可以导出/导入保存查询进度
163 | - 在更改排序方式、更改限定分区,以及在当前/全部收藏夹中搜索时,脚本都能正常工作了(除了先更改排序方式后搜索,在搜索结果界面无法获取排序方式信息)
164 | - 优化
165 | - 简化查询逻辑,将旧的查询流程改叫深度查询,深度查询花时间而作用不大,但保留切换功能
166 | - 将 biliplus 查询到的标题和子P标题信息同步给鼠标悬停浮块,方便一次性复制
167 | - 鼠标悬停浮块增加时长、失效原因信息
168 | - 代码 refactor ,增加可读性
169 |
170 | ### v1.2.1.2 - 2024.12.07
171 | - 修复
172 | - B站推出新界面,适配B站新UI
173 |
174 | ### v1.2.1.1 - 2024.03.07
175 | - 修复
176 | - 原脚本旧B站端口只能用于公开收藏夹,更新B站端口字段,恢复获取所有收藏夹视频的简介等信息
177 | - 旧BV号转AV号算法失效,更新算法,使用了 [bilibili-API-collect](https://github.com/SocialSisterYi/bilibili-API-collect/blob/master/docs/misc/bvid_desc.md) 里的代码
178 | - B站将封面图的img元素放在了picture元素内、与另两个source元素并列,浏览器优先显示source元素,导致新替换上的封面图没显示出来,删除多余的source元素恢复封面展示
179 | - 新增
180 | - 右下角操作菜单增加复制BV号
181 | - 右下角操作菜单增加一键跳转UP主空间
182 | - 优化
183 | - 增加鼠标悬停时浮块的展示信息
184 | - 去掉了原脚本先判断封面图链接有效性后才替换图片的步骤,直接替换新图片链接,反正不会变得更糟
185 |
186 | ### v1.2.1
187 | - Mr-Po 的原版脚本
188 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/bilibili-favorites-fix-cerenkov-mod.js:
--------------------------------------------------------------------------------
1 | // ==UserScript==
2 | // @name 哔哩哔哩(B站|Bilibili)收藏夹Fix (cerenkov修改版)
3 | // @namespace http://tampermonkey.net/
4 | // @version 1.4.4
5 | // @description 修复 哔哩哔哩(www.bilibili.com) 失效的视频收藏、和被up主隐藏的视频。(可查看av号、简介、标题、封面、数据等)
6 | // @note 1.4.* 版本主要更新:
7 | // @note 支持恢复被隐藏(up主设置为“仅自己可见”)的视频信息,让收藏夹不再“缺一角”
8 | // @note 多个数据来源: biliplus jijidown xbeibeix B站官方鉴权API、 B站官方非鉴权API,最大程度恢复信息
9 | // @note 建议将收藏夹设为公开,可以通过 B站官方非鉴权API 查询并恢复很多视频信息,脚本缓存后再改回私密
10 | // @note 查询结果缓存在篡改猴(Tampermonkey)的本地存储,免除对同一个失效视频的反复查询,刷新标签页、关闭浏览器也不再丢失数据
11 | // @author cerenkov
12 | // @license GPL-3.0
13 | // @match *://space.bilibili.com/*/favlist*
14 | // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.0/jquery.min.js
15 | // @resource iconError https://cdn.jsdelivr.net/gh/crnkv/bilibili-favorites-fix-cerenkov-mod/media/error.png
16 | // @resource iconSuccess https://cdn.jsdelivr.net/gh/crnkv/bilibili-favorites-fix-cerenkov-mod/media/success.png
17 | // @resource iconInfo https://cdn.jsdelivr.net/gh/crnkv/bilibili-favorites-fix-cerenkov-mod/media/info.png
18 | // @connect api.bilibili.com
19 | // @connect biliplus.com
20 | // @connect jijidown.com
21 | // @connect xbeibeix.com
22 | // @grant unsafeWindow
23 | // @grant GM.xmlHttpRequest
24 | // @grant GM_notification
25 | // @grant GM_setClipboard
26 | // @grant GM_getResourceURL
27 | // @grant GM_openInTab
28 | // @grant GM_listValues
29 | // @grant GM_setValue
30 | // @grant GM_getValue
31 | // @grant GM_deleteValue
32 | // @grant GM_setValues
33 | // @grant GM_getValues
34 | // @grant GM_deleteValues
35 | // ==/UserScript==
36 |
37 | /*jshint esversion: 8 */
38 | (function() {
39 | 'use strict';
40 |
41 | // 改成true可以启用调试模式
42 | // 注意:如果代码被修改,脚本的自动更新会停止,需要在Tampermonkey编辑器中将脚本重置到出厂,才能恢复自动更新(重置之前请记得先导出缓存备份)
43 | const isDebug = false;
44 |
45 | // 从监测到网页节点变动,到执行脚本修复之间的延迟(秒),延迟太短可能会导致收藏夹翻页的网页渲染未完成而脚本已经开始干预,造成意外后果
46 | const delay = 2.0;
47 |
48 | // 失效收藏的标题文字颜色(默认为灰色)。
49 | const invalTitleColor = "#999";
50 | // 被恢复的隐藏视频的背景颜色
51 | const recoveredItemColor = "#fa2";
52 | // 从分P视频的第一P获取到标题时加以后缀标注
53 | const titleGuessSuffix = " (视频投稿上传时的标题)";
54 |
55 | // 全局变量,用于保存是否B站新网页界面,脚本自动检测
56 | let isNewUI;
57 | // 全局变量,用于保存窗口宽度是否超过1760,脚本自动检测
58 | let isWideScreen;
59 | // 全局变量,用于保存B新/旧界面各自的视频根节点,脚本自动检测
60 | let $rootItem;
61 | // 全局变量,用于保存由B站API端口查询得到的本应展示的视频总数(当中包含被隐藏的视频,即被up主设为“仅自己可见”的视频)
62 | let NTotalItems = undefined;
63 |
64 | // 缓存已经查询过并且有结果的视频标题和封面(包括查到的和查不到的,不包括查询过程中请求过快、网络错误和解析错误的)
65 | let cache = {
66 | clear: function() {
67 | GM_deleteValues(GM_listValues());
68 | },
69 | delete: function(avid, key) {
70 | if (key == undefined) {
71 | GM_deleteValue(avid); // cache.delete(avid) 删除一条avid缓存对象
72 | } else {
73 | let c = GM_getValue(avid, {});
74 | delete c[key];
75 | if (Object.keys(c).length == 0) {
76 | this.delete(avid); // 如果所删除的key是avid缓存对象唯一的key属性,那么将整条avid缓存对象删除
77 | } else {
78 | GM_setValue(avid, c); // cache.delete(avid, key) 删除avid缓存对象的对应key属性
79 | }
80 | }
81 | },
82 | set: function(avid, key, value) {
83 | if (key == undefined) {
84 | value = avid;
85 | if (typeof value !== "object") throw "格式不正确";
86 | GM_setValues(value); // cache.set(value) 把 value 对象内的所有avid项都覆盖保存到所有缓存
87 | } else if (value == undefined) { // 注意永远不要故意传入value=undefined,应该要用delete方法
88 | value = key;
89 | if (typeof value !== "object") throw "格式不正确";
90 | if (Object.keys(value).length == 0) {
91 | this.delete(avid); // cache.set(avid, {}) 删除对应avid缓存对象
92 | } else {
93 | GM_setValue(avid, value); // cache.set(avid, value) 把 value 对象覆盖保存到对应avid缓存对象
94 | }
95 | } else {
96 | if (key == "title")
97 | value = $("").html(value).text(); // decode HTML entities
98 | let c = GM_getValue(avid, {});
99 | c[key] = value;
100 | GM_setValue(avid, c); // cache.set(avid, key, value) 把 value 值覆盖保存到对应avid缓存的对应key属性
101 | }
102 | },
103 | get: function(avid, key, defaultValue) {
104 | if (defaultValue == undefined) { // 注意永远不要故意传入defaultValue=undefined
105 | switch (key) {
106 | case "archive":
107 | defaultValue = undefined; break;
108 | case "title":
109 | case "pic":
110 | case "ff":
111 | case "author":
112 | defaultValue = ""; break;
113 | case "parts":
114 | defaultValue = []; break;
115 | case "tid":
116 | case "thumb_up":
117 | case "coin":
118 | case "reply":
119 | defaultValue = 0; break;
120 | default:
121 | // do nothing
122 | };
123 | }
124 | if (avid == undefined) {
125 | return GM_getValues(GM_listValues()); // cache.get() 返回所有缓存
126 | } else if (key == undefined) {
127 | return GM_getValue(avid, undefined); // cache.get(avid) 返回一条avid缓存对象(未命中时返回 undefined )
128 | } else {
129 | let v = GM_getValue(avid, {})[key]; // cache.get(avid, key) 返回对应avid缓存的对应key属性(未命中时返回 switch-case 指定的 defaultValue )
130 | return v == undefined ? defaultValue : v; // cache.get(avid, key, defaultValue) 返回对应avid缓存的对应key属性(未命中时返回 defaultValue )
131 | }
132 | },
133 | update: function(avid, key, newValue) {
134 | let oldValue = this.get(avid, key);
135 | if (!newValue || newValue === oldValue) return oldValue;
136 | let isBetter = false;
137 | switch (key) {
138 | case "archive":
139 | isBetter = (oldValue == undefined && newValue !== undefined) || (oldValue == "nohit" && (newValue == "bp" || newValue == "jj")) || (oldValue == "jj" && newValue == "bp");
140 | break;
141 | case "title":
142 | newValue = $("").html(newValue).text().trim(); // decode HTML entities
143 | if (newValue == "" || newValue == "已失效视频" || newValue == avid) break;
144 | isBetter = (oldValue == "" || oldValue == "已失效视频") || (oldValue.includes(titleGuessSuffix) && !newValue.includes(titleGuessSuffix));
145 | break;
146 | case "pic":
147 | if (/bfs\/archive\/be27fd62c99036dce67efface486fb0a88ffed06/i.test(newValue)) break;
148 | if (newValue.includes("@")) newValue = newValue.match(/([^@]*)@/)[1];
149 | isBetter = (oldValue == "" && newValue !== "") || (!/bfs\/archive/i.test(oldValue) && /bfs\/archive/i.test(newValue));
150 | break;
151 | case "ff":
152 | isBetter = oldValue == "" && newValue !== "";
153 | break;
154 | case "author":
155 | isBetter = oldValue == "" && newValue !== "" && newValue !== "账号已注销";
156 | case "parts":
157 | isBetter = oldValue.length < 2 && newValue.length > 1;
158 | break;
159 | case "tid":
160 | isBetter = (!oldValue) && (!!newValue);
161 | break;
162 | case "thumb_up":
163 | case "coin":
164 | case "reply":
165 | isBetter = (!!newValue) && newValue > oldValue;
166 | break;
167 | default:
168 | // do nothing
169 | }
170 | if (isBetter) {
171 | this.set(avid, key, newValue);
172 | return newValue;
173 | } else {
174 | return oldValue;
175 | }
176 | },
177 | export: function() {
178 | return JSON.stringify(this.get());
179 | },
180 | import: function(str) {
181 | let incremental = str[0] == "+";
182 | if (incremental) str = str.slice(1);
183 | let json = JSON.parse(str);
184 | if (typeof json !== "object") {
185 | throw "JSON格式不正确";
186 | } else {
187 | for (let avid in json) {
188 | if (typeof json[avid] !== "object")
189 | throw "JSON格式不正确";
190 | if (json[avid].success == true) {
191 | json[avid].archive = "bp";
192 | }
193 | delete json[avid].success;
194 | }
195 | }
196 | if (incremental) {
197 | for (let avid in json) {
198 | this.set(avid, json[avid]);
199 | }
200 | } else {
201 | this.clear();
202 | this.set(json);
203 | }
204 | }
205 | };
206 |
207 | const categoriesArray = [["全部分区", 0], ["动画", 1], ["音乐", 3], ["游戏", 4], ["娱乐", 5], ["电视剧", 11], ["番剧", 13], ["单机游戏", 17], ["Mugen", 19], ["宅舞", 20], ["日常", 21], ["鬼畜调教", 22], ["电影", 23], ["MAD·AMV", 24], ["MMD·3D", 25], ["音MAD", 26], ["综合", 27], ["原创音乐", 28], ["音乐现场", 29], ["VOCALOID·UTAU", 30], ["翻唱", 31], ["完结动画", 32], ["连载动画", 33], ["完结剧集", 34], ["知识", 36], ["人文·历史", 37], ["演讲·公开课", 39], ["短片·手书", 47], ["资讯", 51], ["演奏", 59], ["网络游戏", 65], ["综艺", 71], ["动物综合", 75], ["美食制作", 76], ["其他国家", 83], ["小剧场", 85], ["特摄", 86], ["数码", 95], ["星海", 96], ["机械", 98], ["鬼畜", 119], ["GMV", 121], ["野生技术协会", 122], ["社科·法律·心理", 124], ["人力VOCALOID", 126], ["教程演示", 127], ["舞蹈", 129], ["音乐综合", 130], ["Korea相关", 131], ["音游", 136], ["明星综合", 137], ["搞笑", 138], ["欧美电影", 145], ["日本电影", 146], ["华语电影", 147], ["官方延伸", 152], ["国产动画", 153], ["舞蹈综合", 154], ["时尚", 155], ["舞蹈教程", 156], ["美妆护肤", 157], ["穿搭", 158], ["时尚潮流", 159], ["生活", 160], ["手工", 161], ["绘画", 162], ["运动", 163], ["健身", 164], ["广告", 165], ["国创", 167], ["国产原创相关", 168], ["布袋戏", 169], ["资讯", 170], ["电子竞技", 171], ["手机游戏", 172], ["桌游棋牌", 173], ["其他", 174], ["汽车生活", 176], ["纪录片", 177], ["科学·探索·自然", 178], ["军事", 179], ["社会·美食·旅行", 180], ["影视", 181], ["影视杂谈", 182], ["影视剪辑", 183], ["预告·资讯", 184], ["国产剧", 185], ["海外剧", 187], ["科技", 188], ["电脑装机", 189], ["摄影摄像", 190], ["影音智能", 191], ["风尚标", 192], ["MV", 193], ["电音", 194], ["动态漫·广播剧", 195], ["街舞", 198], ["明星舞蹈", 199], ["国风舞蹈", 200], ["科学科普", 201], ["资讯", 202], ["热点", 203], ["环球", 204], ["社会", 205], ["综合", 206], ["财经商业", 207], ["校园学习", 208], ["职业职场", 209], ["手办·模玩", 210], ["美食", 211], ["美食侦探", 212], ["美食测评", 213], ["田园美食", 214], ["美食记录", 215], ["鬼畜剧场", 216], ["动物圈", 217], ["喵星人", 218], ["汪星人", 219], ["动物二创", 220], ["野生动物", 221], ["小宠异宠", 222], ["汽车", 223], ["汽车文化", 224], ["汽车极客", 225], ["智能出行", 226], ["购车攻略", 227], ["人文历史", 228], ["设计·创意", 229], ["软件应用", 230], ["计算机技术", 231], ["科工机械", 232], ["极客DIY", 233], ["运动", 234], ["篮球", 235], ["竞技体育", 236], ["运动文化", 237], ["运动综合", 238], ["家居房产", 239], ["摩托车", 240], ["娱乐杂谈", 241], ["粉丝创作", 242], ["乐评盘点", 243], ["音乐教学", 244], ["赛车", 245], ["改装玩车", 246], ["新能源车", 247], ["房车", 248], ["足球", 249], ["出行", 250], ["三农", 251], ["仿妆cos", 252], ["动漫杂谈", 253], ["亲子", 254], ["手势·网红舞", 255], ["短片", 256], ["配音", 257], ["汽车知识科普", 258], ["版权内容", -24]];
208 | const categoriesDictReversed = Object.fromEntries(categoriesArray);
209 | const categoriesDict = Object.fromEntries(categoriesArray.map(x => x.reverse()));
210 |
211 | var XOR_CODE = 23442827791579n;
212 | var MASK_CODE = 2251799813685247n;
213 | var BASE = 58n;
214 | var CHAR_TABLE = "FcwAPNKTMug3GV5Lj7EJnHpWsx4tb8haYeviqBz6rkCy12mUSDQX9RdoZf";
215 |
216 | function bv2av(bvid) {
217 | const bvidArr = Array.from(bvid);
218 | [bvidArr[3], bvidArr[9]] = [bvidArr[9], bvidArr[3]];
219 | [bvidArr[4], bvidArr[7]] = [bvidArr[7], bvidArr[4]];
220 | bvidArr.splice(0, 3);
221 | const tmp = bvidArr.reduce((pre, bvidChar) => pre * BASE + BigInt(CHAR_TABLE.indexOf(bvidChar)), 0n);
222 | return Number((tmp & MASK_CODE) ^ XOR_CODE);
223 | }
224 |
225 | async function fetchJSON(url) {
226 | if (isDebug) console.log(`[bilibili-fav-fix] fetchJSON for ${url}`);
227 | let res = await GM.xmlHttpRequest({
228 | method: 'GET',
229 | url: url,
230 | responseType: "json"
231 | }).catch(e => {
232 | console.error(e); // e里含有网络请求对象,res里不含
233 | });
234 | if (isDebug) console.log(res);
235 | if (!res) {
236 | tipError(`收藏夹修复错误:${url} 网站无法访问,可能需要检查网络连接并手动刷新重试`);
237 | return null;
238 | } else if (res.status == 502 || res.status == 503) { // jijidown 和 biliplus 的常见错误,应该是请求过于频繁
239 | console.error(`[bilibili-fav-fix] network connection with status code ${res.status}: ${url}`);
240 | if (url.includes("biliplus")) { // 让返回值可以被优雅地解读为请求过快并处理
241 | return {code: -503};
242 | } else if (url.includes("jijidown")) {
243 | return {code: 0};
244 | }
245 | } else if (res.status !== 200) {
246 | console.error(`[bilibili-fav-fix] network connection with status code ${res.status}: ${url}`);
247 | // tipError(`收藏夹修复错误:${url} 网站无法访问(错误代码${res.status}),可能需要检查网络连接并手动刷新重试`);
248 | return null;
249 | } else if (res.response == undefined) {
250 | console.error(`[bilibili-fav-fix] website not responding in a valid JSON format: ${url}`);
251 | tipError(`收藏夹修复错误:${url} 网站返回的数据格式不正确`);
252 | return null;
253 | } else {
254 | return res.response;
255 | }
256 | }
257 |
258 | async function fetchHTMLDoc(url) {
259 | if (isDebug) console.log(`[bilibili-fav-fix] fetchHTML for ${url}`);
260 | let res = await GM.xmlHttpRequest({
261 | method: 'GET',
262 | url: url,
263 | redirect: "manual",
264 | cookiePartition: {
265 | topLevelSite: 'https://xbeibeix.com'
266 | }
267 | }).catch(e => {
268 | console.error(e); // e里含有网络请求对象,res里不含
269 | });
270 | if (isDebug) console.log(res);
271 | if (!res) {
272 | tipError(`收藏夹修复错误:${url} 网站无法访问,可能需要检查网络连接并手动刷新重试`);
273 | return null;
274 | } else if (res.status == 403) {
275 | if (isDebug) console.log(`[bilibili-fav-fix] network connection with status code ${res.status}: ${url}`);
276 | return "verifyHuman";
277 | } else if ((res.status == 301 || res.status == 302) && res.responseHeaders.match(/\nlocation:\/\r?\n/i)) {
278 | if (isDebug) console.log(`[bilibili-fav-fix] network connection redirected to homepage: ${url}`);
279 | return "redirected";
280 | } else if (res.status !== 200) {
281 | console.error(`[bilibili-fav-fix] network connection with status code ${res.status}: ${url}`);
282 | // tipError(`收藏夹修复错误:${url} 网站无法访问(错误代码${res.status}),可能需要检查网络连接并手动刷新重试`);
283 | return null;
284 | } else {
285 | try {
286 | let doc = new DOMParser().parseFromString(res.responseText, 'text/html');
287 | if (isDebug) console.log(doc);
288 | return doc;
289 | } catch (e) {
290 | console.error(`[bilibili-fav-fix] website not responding in a valid HTML format: ${url}`);
291 | tipError(`收藏夹修复错误:${url} 网站返回的数据格式不正确`);
292 | return null;
293 | }
294 | }
295 | }
296 |
297 |
298 | // 脚本主入口
299 | // 函数调用逻辑:
300 | // - handleFavorites 调用 startBilibiliApiQuery startBiliplusQuery 和 queryCached (如果命中缓存)
301 | // - startBiliplusQuery 调用 queryHit (如果查询有结果)和 startJijidownQuery (如果查询无结果)
302 | // - startJijidownQuery 调用 queryHit (如果查询有结果)和 startXbeibeixQuery (如果查询无结果)
303 | // - startXbeibeixQuery 调用 queryHit (如果查询有结果)和 queryFailed(如果查询无结果)
304 | // - queryHit 条件性调用 refineBiliplusQuery (如果有 refine 需求)
305 | // - queryFailed 调用 queryCached
306 | // - queryCached 条件性调用 refineBiliplusQuery (如果有 refine 需求)
307 | // - startBilibiliApiQuery 设定是否需要 refine 的条件,且条件性调用 recoverHiddenItems
308 | // - 最终负责执行的是 setTitleLink setTitleText setCoverPic setTooltip replaceTooltip replaceAuthorText 等等
309 | function handleFavorites() {
310 | if (isDebug) console.log(`[bilibili-fav-fix] isNewUI: ${isNewUI}`);
311 |
312 | // 失效收藏节点集
313 | let $allItems = getAllItems().toArray().map(item => $(item));
314 | let $targetItems = [];
315 | if (isNewUI) {
316 | $targetItems = $allItems.filter($item => $item.find(".bili-video-card__title a").first().text() == "已失效视频");
317 | } else if ($("ul.fav-video-list.content").length > 0) {
318 | $targetItems = $allItems.filter($item => $item.hasClass("disabled"));
319 | } else {
320 | console.error('[bilibili-fav-fix] B站网页样式无法识别');
321 | }
322 |
323 | if ($targetItems.length > 0 || NTotalItems == undefined || $allItems.length < NTotalItems) {
324 | if ($targetItems.length > 0)
325 | console.log(`[bilibili-fav-fix] ${$targetItems.length}个失效收藏待修复...`);
326 | if (NTotalItems == undefined) {
327 | if (isDebug) console.log(`[bilibili-fav-fix] 潜在可能有被隐藏的收藏待修复...`);
328 | } else if ($allItems.length < NTotalItems) {
329 | console.log(`[bilibili-fav-fix] ${NTotalItems - $allItems.length}个被隐藏的收藏待修复...`);
330 | }
331 |
332 | // 预处理 $allItems $targetItems 移除多余元素和样式 添加功能菜单
333 | $allItems.forEach(function($item) {
334 | setupItem($item);
335 | });
336 | $targetItems.forEach(function($item) {
337 | if (isDebug) console.log(`[bilibili-fav-fix] item needed to fix: ${$item.attr("bvid")} ( ${$item.attr("avid")} )`);
338 | // 移除无效的备用封面(有一版B站UI用过这种设计)
339 | $item.find("source").remove();
340 | // 移除旧UI的禁用样式
341 | if (!isNewUI) {
342 | $item.removeClass("disabled");
343 | getCoverElem($item).removeClass("disabled")
344 | getTitleElem($item).removeClass("disabled");
345 | }
346 | // 添加功能菜单
347 | addCopyAVIDButton($item);
348 | addCopyBVIDButton($item);
349 | addCopyInfoButton($item);
350 | addOpenPicButton($item);
351 | addSaveLoadCacheButton($item);
352 | // addDeleteThisButton($item);
353 | });
354 |
355 | startBilibiliApiQuery($targetItems, $allItems);
356 |
357 | // 分离已缓存条目和待查询条目
358 | let $queryItems = {};
359 | $targetItems.forEach(function($item) {
360 | const avid = $item.attr("avid");
361 | let c = cache.get(avid);
362 | if (c && c.archive !== undefined) { // c.archive 无论是 bp jj 还是 nohit ,都表明biliplus或jijidown的查询结果都已保存在cache中
363 | queryCached($item, avid, c);
364 | } else { // 完全没查询过,或者只保存了biliAPI的查询结果,未查清、缓存biliplus或jijidown的查询结果
365 | $queryItems[avid] = $item;
366 | }
367 | });
368 |
369 | if (Object.keys($queryItems).length > 0)
370 | startBiliplusQuery($queryItems);
371 | }
372 | }
373 |
374 | async function startBiliplusQuery($queryItems) {
375 | let avids = Object.keys($queryItems);
376 | if (isDebug) console.log(`[bilibili-fav-fix] startBiliplusQuery for ${avids.length} items: ${avids.join(', ')}`);
377 | for (let $item of Object.values($queryItems)) {
378 | setTitleText($item, "正在查询 biliplus ...");
379 | }
380 | const json = await fetchJSON(`https://www.biliplus.com/api/aidinfo?aid=${avids.join(',')}`);
381 | if (!json) { // 由于网络请求遇到故障中断、网站暂时下线等,重试也无益,姑且尝试jijidown,不代表biliplus上真的没数据
382 | startJijidownQuery($queryItems, false);
383 | } else if (json.code == -503) { // 请求过快,手动点击重试
384 | if (isDebug) console.log(`[bilibili-fav-fix] biliplus 请求过快 for ${avids.length} items: ${avids.join(', ')}`);
385 | for (let $item of Object.values($queryItems)) {
386 | setTitleRetry($item, {items: $queryItems}, function(event) {
387 | event.preventDefault();
388 | let $queryIts = event.data.items; // 取出成局部变量,以便.off()时销毁event.data,函数结束后亦销毁局部变量
389 | for (let $it of Object.values($queryIts)) {
390 | getTitleElem($it).off("click");
391 | }
392 | startBiliplusQuery($queryIts);
393 | });
394 | }
395 | } else if (json.code !== 0) { // json.code == -404 全无记录 -403 访问权限不足(up主隐藏)
396 | if (isDebug) console.log(`[bilibili-fav-fix] biliplus no results for ${avids.length} items: ${avids.join(', ')}`);
397 | startJijidownQuery($queryItems);
398 | } else { // 至少部分avid有记录
399 | if (isDebug) console.log(`[bilibili-fav-fix] biliplus has ${Object.keys(json.data).length} hits`);
400 | for (let avid in json.data) {
401 | if (isDebug) console.log(`[bilibili-fav-fix] biliplus retrieved info for ${avid}`);
402 | let info = json.data[avid];
403 | let $item = $queryItems[avid];
404 | let pic = cache.update(avid, "pic", info.pic);
405 | queryHit($item, avid, info.title, pic, info.author, "bp");
406 | if (!/bfs\/archive/i.test(pic)) { // 极大概率是失效的旧图片链接
407 | if (isDebug) console.log(`[bilibili-fav-fix] query for better pic for ${avid}`);
408 | startJijidownQuery(Object.fromEntries([[avid, $item]]), false, true);
409 | }
410 | delete $queryItems[avid];
411 | }
412 | if (Object.keys($queryItems).length > 0)
413 | startJijidownQuery($queryItems);
414 | }
415 | }
416 |
417 |
418 | function startJijidownQuery($queryItems, isDecisive = true, isForPic = false, silent = true) {
419 | if (isDebug) console.log(`[bilibili-fav-fix] startJijidownQuery for ${Object.keys($queryItems).length} items`);
420 | for (let [avid, $item] of Object.entries($queryItems)) { // 并发网络请求 for 循环
421 | if (isDebug) console.log(`[bilibili-fav-fix] startJijidownQuery for ${avid}`);
422 | if (!isForPic) {
423 | setTitleText($item, "正在查询 jijidown ...");
424 | } else if (!silent) {
425 | setTitleText($item, "正从 jijidown 查询封面图 ..."); // 若仅查找封面图则意味着标题已找到,默认不改动显示标题,除非需要重置已修改的标题
426 | }
427 | fetchJSON(`https://www.jijidown.com/api/v1/video/get_info?id=${avid}`)
428 | .then(json => {
429 | if (!json) { // 由于网络请求遇到故障中断、网站暂时下线等,重试也无益
430 | startXbeibeixQuery($item, avid, false, isForPic, silent);
431 | } else if (json.code == 0 || json.upid == undefined) { // 大概率是请求过快
432 | if (isDebug) console.log(`[bilibili-fav-fix] jijidown 请求过快 ${avid}`);
433 | setTitleRetry($item, {item: $item}, function(event) {
434 | event.preventDefault();
435 | let $it = event.data.item; // 取出成局部变量,以便.off()时销毁event.data,函数结束后亦销毁局部变量
436 | $(this).off("click");
437 | startJijidownQuery(Object.fromEntries([[$it.attr("avid"), $it]]), isDecisive, isForPic, false);
438 | });
439 | } else if (json.upid == -1 || json.upid == 0 || json.title == "视频去哪了呢?" || json.title == "该视频或许已经被删除了" || (json.title == avid && json.img == "")) {
440 | if (isDebug) console.log(`[bilibili-fav-fix] jijidown failed for ${avid}`);
441 | startXbeibeixQuery($item, avid, isDecisive, isForPic, silent);
442 | } else {
443 | if (isDebug) console.log(`[bilibili-fav-fix] jijidown retrieved info for ${avid}`);
444 | let pic = cache.update(avid, "pic", json.img);
445 | if (!isForPic) {
446 | queryHit($item, avid, json.title, pic, json.up.author, isDecisive ? "jj" : undefined);
447 | } else {
448 | if (!silent) setTitleText($item, cache.get(avid, "title"), true);
449 | setCoverPic($item, pic, cache.get(avid, "ff"));
450 | if (/bfs\/archive/i.test(pic))
451 | if (isDebug) console.log(`[bilibili-fav-fix] jijidown got better pic for ${avid}`);
452 | }
453 | if (!/bfs\/archive/i.test(pic)) { // 极大概率是失效的旧图片链接
454 | if (isDebug) console.log(`[bilibili-fav-fix] query for better pic for ${avid}`);
455 | startXbeibeixQuery($item, avid, false, true);
456 | }
457 | }
458 | });
459 | }
460 | }
461 |
462 |
463 | async function startXbeibeixQuery($item, avid, isDecisive = true, isForPic = false, silent = true) {
464 | if (isDebug) console.log(`[bilibili-fav-fix] startXbeibeixQuery for ${avid}`);
465 | if (!isForPic) {
466 | setTitleText($item, "正在查询 xbeibeix ...");
467 | } else if (!silent) {
468 | setTitleText($item, "正从 xbeibeix 查询封面图 ..."); // 若仅查找封面图则意味着标题已找到,默认不改动显示标题,除非需要重置已修改的标题
469 | }
470 | const doc = await fetchHTMLDoc(`https://xbeibeix.com/video/${$item.attr("bvid")}`);
471 | if (!doc) {
472 | if (!isForPic) {
473 | queryFailed($item, avid);
474 | } else {
475 | if (!silent) setTitleText($item, cache.get(avid, "title"), true);
476 | }
477 | } else if (doc == "redirected") {
478 | if (isDebug) console.log(`[bilibili-fav-fix] xbeibeix failed for ${avid}`);
479 | if (isDecisive) cache.update(avid, "archive", "nohit");
480 | if (!isForPic) {
481 | queryFailed($item, avid);
482 | } else {
483 | if (!silent) setTitleText($item, cache.get(avid, "title"), true);
484 | }
485 | } else if (doc == "verifyHuman" || doc.querySelector('meta[name="robots"]')) {
486 | if (isDebug) console.log(`[bilibili-fav-fix] xbeibeix need to verify human for ${$item.attr("bvid")} ( ${avid} )`);
487 | getTitleElem($item).addClass("verifyHuman");
488 | setTitleText($item, "请点击验证真实人类,而后关闭该标签页");
489 | getTitleElem($item).on("click", {item: $item}, function(event) {
490 | event.preventDefault();
491 | let $it = event.data.item;
492 | if ($(this).hasClass("verifyHuman")) {
493 | const tab = GM_openInTab(`https://xbeibeix.com/video/${$it.attr("bvid")}`, {active: true, insert: true, setParent: true});
494 | tab.onclose = function() {
495 | if (isDebug) console.log(`[bilibili-fav-fix] human verification completed for ${$it.attr("bvid")} ( ${avid} )`);
496 | let $titleElems = $(".verifyHuman");
497 | $titleElems.removeClass("verifyHuman");
498 | $titleElems.trigger("click");
499 | };
500 | } else {
501 | $(this).off("click");
502 | startXbeibeixQuery($it, avid, isDecisive, isForPic, false);
503 | }
504 | });
505 | } else {
506 | if (isDebug) console.log(`[bilibili-fav-fix] xbeibeix retrieved info for ${avid}`);
507 | let title = doc.querySelector(".fw-bold").textContent;
508 | let pic = cache.update(avid, "pic", doc.querySelector("img.img-thumbnail").getAttribute("src"));
509 | let author = doc.querySelector("input").getAttribute("value");
510 | if (!isForPic) {
511 | queryHit($item, avid, title, pic, author, isDecisive ? "bb" : undefined);
512 | } else {
513 | if (!silent) setTitleText($item, cache.get(avid, "title"), true);
514 | setCoverPic($item, pic, cache.get(avid, "ff"));
515 | if (/bfs\/archive/i.test(pic))
516 | if (isDebug) console.log(`[bilibili-fav-fix] xbeibeix got better pic for ${avid}`);
517 | }
518 | if (!/bfs\/archive/i.test(pic)) { // 极大概率是失效的旧图片链接
519 | if (isDebug) console.log(`[bilibili-fav-fix] xbeibeix failed for valid pic for ${avid}`);
520 | // 终止封面图查询
521 | }
522 | }
523 | }
524 |
525 |
526 | function queryHit($item, avid, title, pic, author, archive) {
527 | if (isDebug) console.log(`[bilibili-fav-fix] queryHit for ${avid}`);
528 | // 检查refine需求
529 | if (archive == "bp") {
530 | if ($item.attr("_refineParts") == "needRefine") {
531 | $item.attr("_refineParts", "");
532 | refineBiliplusQuery($item, avid);
533 | } else {
534 | $item.attr("_refineParts", "canRefine");
535 | }
536 | }
537 | // 仅在hit函数时才更新archive,failed或cached时在调用函数前更新
538 | cache.update(avid, "archive", archive); // 取值bp jj 或undefined
539 | // 设置超链接
540 | if (archive == "bp") {
541 | setTitleLink($item, `https://www.biliplus.com/video/av${avid}/`);
542 | } else if (archive == "jj") {
543 | setTitleLink($item, `https://www.jijidown.com/api/v1/video/get_info?id=${avid}`);
544 | } else if (archive == "bb") {
545 | setTitleLink($item, `https://xbeibeix.com/video/${$item.attr("bvid")}`);
546 | } // 明明是queryHit 但却archive==undefined以至于没有coverLink的情况存在,就是biliplus网络故障中断,暂由jijidown得到hit的时候
547 | // 设置标题
548 | cache.update(avid, "title", title);
549 | setTitleText($item, title, true);
550 | getTitleElem($item).attr("_handover", "true");
551 | replaceTooltip($item, /\n标题:.*\n/, `\n标题:${title}\n`); // 总是替换标题,不管浮块是否生成
552 |
553 | // 设置封面图
554 | pic = cache.update(avid, "pic", pic);
555 | setCoverPic($item, pic, cache.get(avid, "ff"));
556 |
557 | // 设置up主名称
558 | if ($item.attr("_author") == "needAuthor") { // 仅当biliAPI获取不到up名称时替换up名称
559 | cache.update(avid, "author", author);
560 | replaceTooltip($item, /\nUP主:.* (https:\/\/space\.bilibili\.com/, `\nUP主:${author} (https://space.bilibili.com`);
561 | replaceAuthorText($item, author);
562 | } else {
563 | $item.attr("_author", author); // 默认不进入缓存,因为不知道biliAPI是否返回“账号已注销”
564 | }
565 | }
566 |
567 |
568 | function queryFailed($item, avid) {
569 | if (isDebug) console.log(`[bilibili-fav-fix] queryFailed for ${avid}`);
570 | let c = cache.get(avid) || {};
571 | queryCached($item, avid, c);
572 | }
573 |
574 |
575 | function queryCached($item, avid, c) {
576 | if (isDebug) console.log(`[bilibili-fav-fix] queryCached for ${avid}`);
577 | // 检查refine需求
578 | if (c.archive == "bp") {
579 | if ($item.attr("_refineParts") == "needRefine") {
580 | $item.attr("_refineParts", "");
581 | refineBiliplusQuery($item, avid);
582 | } else {
583 | $item.attr("_refineParts", "canRefine");
584 | }
585 | }
586 | // 设置超链接
587 | if (c.archive == "bp") {
588 | setTitleLink($item, `https://www.biliplus.com/video/av${avid}/`);
589 | } else if (c.archive == "jj") {
590 | setTitleLink($item, `https://www.jijidown.com/api/v1/video/get_info?id=${avid}`);
591 | } else if (c.archive == "bb") {
592 | setTitleLink($item, `https://xbeibeix.com/video/${$item.attr("bvid")}`);
593 | }
594 | // 设置标题
595 | if (c.title) { // 有缓存title则先显示,可能会被biliAPI之后修改
596 | setTitleText($item, c.title, true); // 仅当成功恢复时修改样式
597 | } else if (getTitleElem($item).attr("_noguesses") == "true") { // 没有缓存,biliAPI也没有
598 | setTitleText($item, `查不到标题(${avid})【鼠标悬停查看简介】`);
599 | } else { // 没有缓存,但biliAPI之后可能有
600 | setTitleText($item, `正在查询 bilibili API ...`);
601 | }
602 | getTitleElem($item).attr("_handover", "true");
603 |
604 | // 设置封面图
605 | setCoverPic($item, c.pic, c.ff);
606 | }
607 |
608 |
609 | async function refineBiliplusQuery($item, avid, retry = 0) {
610 | if (isDebug) console.log(`[bilibili-fav-fix] refineBiliplusQuery for ${avid}`);
611 | const json = await fetchJSON(`https://www.biliplus.com/api/view?id=${avid}`);
612 | if (!json) { // 网络连接故障中断或JSON格式错误
613 | return;
614 | } else if (json.code == -503) { // 请求过快
615 | if (retry < 2) { // 仅自动重试两次,但由于needRefine始终存在,以后还会有重试的机会
616 | if (isDebug) console.log(`[bilibili-fav-fix] refineBiliplusQuery 请求过快,10秒后重试`);
617 | setTimeout(refineBiliplusQuery, 10000, $item, avid, retry + 1);
618 | }
619 | return;
620 | } else if (json.code == -404) { // 查询无结果
621 | return;
622 | } else if (json.code == -403) { // 访问权限不足(up主隐藏)
623 | return;
624 | }
625 | if (json.list && json.list.length > 1) {
626 | if (isDebug) console.log(`[bilibili-fav-fix] refined biliplus got ${json.list.length} parts for ${avid}`);
627 | let parts = json.list.map(x => x.part);
628 | parts = cache.update(avid, "parts", parts);
629 | let partsStr = parts.map(part => `* ${part}\n`).join('');
630 | replaceTooltip($item, "\n播放数:", `\n子P标题:\n${partsStr}播放数:`);
631 | }
632 | if (Number(json.tid)) {
633 | let tid = cache.update(avid, "tid", Number(json.tid));
634 | replaceTooltip($item, /\n分区:.*\n/, `\n分区:${categoriesDict[tid]}\n`);
635 | }
636 | if (Number(json.coins)) {
637 | let coin = cache.update(avid, "coin", Number(json.coins));
638 | let content = getCoverElem($item).attr("title");
639 | if (content && content.includes("\n投币数:")) {
640 | replaceTooltip($item, /\n投币数:.*\n/, `\n投币数:${coin}\n`);
641 | } else {
642 | replaceTooltip($item, "\n失效原因:", `\n投币数:${coin}\n失效原因:`)
643 | }
644 | }
645 | if (Number(json.review)) {
646 | let reply = cache.update(avid, "reply", Number(json.review));
647 | let content = getCoverElem($item).attr("title");
648 | if (content && content.includes("\n回复数:")) {
649 | replaceTooltip($item, /\n回复数:.*\n/, `\n回复数:${reply}\n`);
650 | } else {
651 | replaceTooltip($item, "\n失效原因:", `\n回复数:${reply}\n失效原因:`)
652 | }
653 | }
654 | // 将first_frame更新成备用的封面图,但其实没多大用。如果biliplus和jijidown都返回无效的pic那么基本找不到ff,如果有ff那么基本上pic都是有效的
655 | if (json.v2_app_api && json.v2_app_api.first_frame) {
656 | let ff = json.v2_app_api.first_frame;
657 | if (isDebug) console.log(`[bilibili-fav-fix] refined biliplus got first_frame pic for ${avid}: ${ff}`);
658 | ff = cache.update(avid, "ff", ff);
659 | const $imgElem = getImgElem($item);
660 | if ($imgElem.attr("alt") == "图片链接失效") { // pic已经被替换进img元素,且执行替换时无ff
661 | $imgElem.attr("alt", " ");
662 | $(``).insertAfter($imgElem);
663 | } else if ($imgElem.attr("alt") == " ") { // pic已经被替换进img元素,且执行替换时有ff
664 | $imgElem.next().attr("src", ff);
665 | } else { // pic未被替换进img元素
666 | // do nothing
667 | }
668 | }
669 | }
670 |
671 |
672 | async function startBilibiliApiQuery($targetItems, $allItems) {
673 | if (isDebug) console.log(`[bilibili-fav-fix] startBilibiliApiQuery for ${$targetItems.length} targetItems, ${$allItems.length} allItems and ${NTotalItems} totalItems`);
674 | let apiType;
675 | if (isNewUI) {
676 | apiType = $("div.favlist-info-detail .status").text().trim();
677 | } else {
678 | apiType = $("div.favInfo-details > div:nth-child(3) > span:nth-child(3)").text().trim();
679 | }
680 | if (apiType == "公开") {
681 | apiType = "public";
682 | } else if (apiType == "私密") {
683 | apiType = "private";
684 | } else {
685 | apiType = "public"; // 例如旧UI等未能一一适配的情况,先从 public 开始尝试
686 | }
687 |
688 | let fid = window.location.href.match(/fid=(\d+)/i);
689 | let mid = window.location.href.match(/bilibili\.com\/(\d+)\/favlist/i)[1];
690 | if (fid) {
691 | fid = fid[1];
692 | } else if (isNewUI) {
693 | fid = $("div.fav-sidebar-item:has(.vui_sidebar-item--active)").first().attr("id");
694 | } else {
695 | fid = $("li.fav-item.cur").first().attr("fid");
696 | }
697 | if (!fid) {
698 | let json = await fetchJSON(`https://api.bilibili.com/x/v3/fav/folder/created/list-all?up_mid=${mid}`);
699 | if (!json) return;
700 | fid = json.data.list[0].id;
701 | }
702 |
703 | let pn;
704 | if (isNewUI) {
705 | pn = $("div.vui_pagenation--btns .vui_button.vui_button--active").text().trim();
706 | } else {
707 | pn = $("ul.be-pager li.be-pager-item.be-pager-item-active").text().trim();
708 | }
709 | if (!pn) pn = 1;
710 |
711 | let url = getBilibiliApiUrl(fid, pn, apiType, 1);
712 |
713 | let origFid = fid;
714 | let mixedSearch = !url.includes("&keyword=&") && url.includes("&type=1&"); // 在全部收藏夹里搜索
715 | if (mixedSearch) {
716 | if (isDebug) console.log(`[bilibili-fav-fix] detected: keyword search in all favorites, fetch public fav`);
717 | let json = await fetchJSON(`https://api.bilibili.com/x/v3/fav/folder/created/list-all?up_mid=${mid}`);
718 | if (!json) return; // TODO: (!json)时的下位替代
719 | let publicFavs = json.data.list.filter(fav => fav.attr % 2 == 0);
720 | if (publicFavs.length == 0) return; // TODO: (publicFavs.length == 0)时的下位替代
721 | fid = publicFavs[0].id; // 随便取一个公开收藏夹的fid
722 | apiType = "public";
723 | url = getBilibiliApiUrl(fid, pn, apiType, 1);
724 | }
725 |
726 | let json = await fetchJSON(url);
727 | if (!json) return;
728 |
729 | if (json.code !== 0) { // -403 访问权限不足
730 | if (apiType == "public") {
731 | console.warn(`[bilibili-fav-fix] bilibili public API failed, now use private API`);
732 | mixedSearch = false; // 退回
733 | fid = origFid;
734 | apiType = "private";
735 | url = getBilibiliApiUrl(fid, pn, apiType, 1);
736 | json = await fetchJSON(url);
737 | if (!json) return;
738 | }
739 | if (json.code !== 0) {
740 | console.warn(`[bilibili-fav-fix] bilibili private API failed`);
741 | $targetItems.forEach(function($item) {
742 | getTitleElem($item).attr("_noguesses", "true"); // biliAPI 未能成功获取任何信息
743 | });
744 | return;
745 | }
746 | }
747 |
748 | // 旧的对公开收藏夹的非鉴权API只接受最多数值20的ps参数,与B站新UI渲染时的一页40个视频不相符,需要分成两个part的网络请求来查询
749 | if (isNewUI && apiType == "public") {
750 | let json2 = await fetchJSON(getBilibiliApiUrl(fid, pn, apiType, 2));
751 | if (!json2) return;
752 | if (json2.data?.medias) {
753 | // .medias可以undefined,但如果json2有,那么json也有
754 | for (let i = 0; i < json2.data.medias.length; i++) {
755 | json.data.medias[i+20] = json2.data.medias[i];
756 | }
757 | // 如果窗口宽度超过1760,B站新UI渲染还会变成6乘6,有时需要分成三个part的网络请求
758 | // fetchPart=1,2 for pn%5=1,5; fetchPart=1,2,3 for pn%5=2,3,4
759 | if (isWideScreen && (pn % 5 !== 0) && (pn % 5 !== 1)) {
760 | let json3 = await fetchJSON(getBilibiliApiUrl(fid, pn, apiType, 3));
761 | if (!json3) return;
762 | if (json3.data?.medias) {
763 | for (let i = 0; i < json3.data.medias.length; i++) {
764 | json.data.medias[i+40] = json3.data.medias[i];
765 | }
766 | }
767 | }
768 | }
769 | if (isWideScreen) {
770 | let start = (pn % 5) == 1 ? 0 : (5 - (pn - 1) % 5) * 4;
771 | json.data.medias = json.data.medias.slice(start, start+36);
772 | }
773 | }
774 |
775 | let medias = json?.data?.medias || []; // .medias可以undefined
776 |
777 | if (mixedSearch) {
778 | if (isDebug) console.log(`[bilibili-fav-fix] also fetch private fav for complement`);
779 | // 使用privateAPI得到B站搜索原本展示的视频列表(包含私密收藏夹内容),以此为base,将publicAPI(不含私密收藏夹内容但包含up主隐藏视频)的丰富信息更新、替换上去
780 | let json = await fetchJSON(getBilibiliApiUrl(fid, pn, "private", 1));
781 | if (!json) return;
782 | let baseMedias = json.data.medias;
783 | let i = -1;
784 | for (let media of medias) {
785 | let match = baseMedias.map(m => m.id).indexOf(media.id);
786 | if (match == -1) {
787 | // 在publicAPI medias里面 而不在privateAPI baseMedia(实际展示)里面
788 | if (media.rights?.autoplay == 0) { // up主隐藏视频
789 | i = i+1;
790 | baseMedias.splice(i, 0, media);
791 | if (isDebug) console.log(`[bilibili-fav-fix] ${i} ${media.title} inserted`);
792 | } else { // 并非隐藏,仅仅是不出现在这一页的privateAPI搜索结果中而已
793 | if (isDebug) console.log(`[bilibili-fav-fix] ${media.title} ignored (not hidden, just not on this page)`);
794 | }
795 | } else {
796 | i = match;
797 | baseMedias.splice(i, 1, media);
798 | if (isDebug) console.log(`[bilibili-fav-fix] ${i} ${media.title} replaced`);
799 | }
800 | }
801 | medias = baseMedias;
802 | }
803 |
804 | NTotalItems = medias.length;
805 | if (isDebug) console.log(`[bilibili-fav-fix] ${NTotalItems} items in total, ${$allItems.length} items visible`);
806 |
807 | if (apiType == "public" && $allItems.length < NTotalItems)
808 | recoverHiddenItems($allItems, medias, $targetItems);
809 |
810 | // showDetails($targetItems, medias)
811 | $targetItems.forEach(function($item) {
812 | const bvid = $item.attr("bvid");
813 | const avid = $item.attr("avid");
814 | if (isDebug) console.log(`[bilibili-fav-fix] showDetails: ${bvid} (${avid})`);
815 |
816 | let media = medias.filter(m => m.bvid == bvid);
817 | if (media.length > 0) {
818 | media = media[0];
819 | if (isDebug) console.log(media);
820 | } else {
821 | console.error(`[bilibili-fav-fix] ${bvid} not found in Bilibili API JSON (wrong params?): ${getBilibiliApiUrl(fid, pn, apiType, 1)}`);
822 | return;
823 | }
824 |
825 | // 设置标题
826 | if (media.title == "" || media.title == "已失效视频")
827 | if (media.page == 1 && media.pages && media.pages.length == 1 && media.pages[0].title !== "" && media.pages[0].title !== "已失效视频")
828 | media.title = media.pages[0].title + titleGuessSuffix; // 从分P 的第一P 的 title 推测
829 | media.title = cache.update(avid, "title", media.title); // 潜在的第一P标题会可能进入缓存
830 |
831 | if (getTitleElem($item).attr("_handover") == "true") { // 在biliplus和jijidown未有结果(handover)之前,title留作交互提示使用而不做改动
832 | if (media.title) {
833 | setTitleText($item, media.title, true);
834 | } else {
835 | setTitleText($item, `查不到标题(${avid})【鼠标悬停查看简介】`);
836 | }
837 | }
838 | if (!media.title) getTitleElem($item).attr("_noguesses", "true"); // 如果biliAPI先得到信息,那么将其失败记录在案
839 |
840 | // 判断分P信息是否完整
841 | let parts = [];
842 | if (media.page > 1 && media.pages && media.pages.length > 1)
843 | parts = media.pages.map(page => page.title).filter(p => p !== "" && p !== "已失效视频"); // 从分P 信息的 title key 读取
844 | parts = cache.update(avid, "parts", parts);
845 | if (media.page == 0 || (media.page > 1 && parts.length < 2)) {
846 | if ($item.attr("_refineParts") == "canRefine") {
847 | refineBiliplusQuery($item, avid);
848 | } else {
849 | $item.attr("_refineParts", "needRefine");
850 | }
851 | }
852 |
853 | // 设置up主名称
854 | if (media.upper.name == "" || media.upper.name == "账号已注销") {
855 | media.upper.name = cache.update(avid, "author", $item.attr("_author")); // 如果_author有内容就会进入缓存并返回
856 | if (media.upper.name) {
857 | replaceAuthorText($item, media.upper.name);
858 | } else {
859 | $item.attr("_author", "needAuthor");
860 | }
861 | } // 不采用拿到name就update的做法,因为不像title和parts、从公开改成私密就马上看不见、急需缓存救急,所以只处理没有name的情况
862 |
863 | media.tid = cache.update(avid, "tid", media.tid);
864 | media.cnt_info.thumb_up = cache.update(avid, "thumb_up", media.cnt_info.thumb_up);
865 | media.cnt_info.coin = cache.update(avid, "coin", media.cnt_info.coin);
866 | media.cnt_info.reply = cache.update(avid, "reply", media.cnt_info.reply);
867 |
868 | let tips = $item.attr("_tips") ? $item.attr("_tips") : "(提示:尽量将收藏夹设为公开,这样能恢复更多的视频标题和分P。可以等脚本将信息自动缓存到本地后,再改回去私密收藏夹也不迟,此时依然能看到缓存好的视频修复标题)";
869 | setTooltip($item, media, parts, tips);
870 |
871 | if (!isNewUI)
872 | addOpenUpSpaceButton($item, media.upper.mid);
873 | });
874 | }
875 |
876 |
877 | function recoverHiddenItems($allItems, medias, $targetItems) {
878 | if (isDebug) console.log(`[bilibili-fav-fix] recovering ${NTotalItems - $allItems.length} hidden items`);
879 | let allBvids = $allItems.map($item => $item.attr("bvid"));
880 |
881 | let $queryItems = {};
882 | for (let i = 0; i < NTotalItems; i++) {
883 | let media = medias[i];
884 | if (allBvids.includes(media.bvid)) continue;
885 |
886 | if (isDebug) console.log(`[bilibili-fav-fix] recover hidden item: ${media.bvid} (${media.id})`);
887 | let duration = new Date(media.duration * 1000).toISOString().slice(11, 19);
888 | if (duration.slice(0, 2) == "00") duration = duration.slice(3);
889 | let favdate = new Date(media.fav_time * 1000).toLocaleDateString().replaceAll('/', '-');
890 | let pubdate = new Date(media.pubtime * 1000).toLocaleDateString().replaceAll('/', '-');
891 |
892 | // 构造新$item
893 | let $item;
894 | if (isNewUI) {
895 | $item = $(
896 | `