diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index 6014d8476..8ec887bf4 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Offline) -// @version 418.77 +// @version 418.79 // @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -2235,19 +2235,18 @@ class ResourceManager { url, responseType: 'blob', })) - zip.forEach((filename, file) => { - const url = Resource.root + 'min/' + filename + let cache = {} + const files = zip.file(/.+/) + for (const file of files) { + const url = Resource.root + 'min/' + file.name const resource = Object.values(Resource.all).find(it => it.rawUrl === url) - if (resource) { - file.async('text').then(text => { - settings.cache = Object.assign(settings.cache, { - [resource.key]: text - }) - // getHash(text).then(hash => console.log(`full download: saved ${resource.key} (${hash})`)) - console.log(`bundle update: saved ${resource.key}`) - }) + if (resource && !resource.alwaysPreview) { + const text = await file.async('text') + cache[resource.key] = text + console.log(`bundle update: saved ${resource.key}`) } - }) + } + settings.cache = Object.assign(settings.cache, cache) // } else { // const hashJson = await Ajax.monkey({ // url: Resource.root + 'min/bundle.json', diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index 173f3228c..8b3a02e86 100644 --- a/bilibili-evolved.preview-offline.user.js +++ b/bilibili-evolved.preview-offline.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Preview Offline) -// @version 418.77 +// @version 418.79 // @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -2235,19 +2235,18 @@ class ResourceManager { url, responseType: 'blob', })) - zip.forEach((filename, file) => { - const url = Resource.root + 'min/' + filename + let cache = {} + const files = zip.file(/.+/) + for (const file of files) { + const url = Resource.root + 'min/' + file.name const resource = Object.values(Resource.all).find(it => it.rawUrl === url) - if (resource) { - file.async('text').then(text => { - settings.cache = Object.assign(settings.cache, { - [resource.key]: text - }) - // getHash(text).then(hash => console.log(`full download: saved ${resource.key} (${hash})`)) - console.log(`bundle update: saved ${resource.key}`) - }) + if (resource && !resource.alwaysPreview) { + const text = await file.async('text') + cache[resource.key] = text + console.log(`bundle update: saved ${resource.key}`) } - }) + } + settings.cache = Object.assign(settings.cache, cache) // } else { // const hashJson = await Ajax.monkey({ // url: Resource.root + 'min/bundle.json', diff --git a/bilibili-evolved.preview.user.js b/bilibili-evolved.preview.user.js index aeb8c44d6..8575e5249 100644 --- a/bilibili-evolved.preview.user.js +++ b/bilibili-evolved.preview.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Preview) -// @version 1.9.1 +// @version 1.9.2 // @description Bilibili Evolved 的预览版, 可以抢先体验新功能. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -1202,12 +1202,24 @@ class Resource { console.log(`hit cache: ${key}`) resolve(cache) } else { - this.text = onlineData[this.rawUrl] - console.log(`load online data: ${key}`) - settings.cache = Object.assign(settings.cache, { - [key]: this.text - }) - resolve(this.text) + this.text = onlineData[this.url] + // settings.cache = Object.assign(settings.cache, { + // [key]: this.text + // }) + if (text) { + console.log(`load online data: ${key}`) + resolve(this.text) + } else { + Ajax.monkey({ url: this.url }) + .then(text => { + this.text = text + settings.cache = Object.assign(settings.cache, { + [key]: text + }) + resolve(this.text) + }) + .catch(error => reject(error)) + } } } else { Ajax.monkey({ url: this.url }) @@ -2257,19 +2269,18 @@ class ResourceManager { url, responseType: 'blob', })) - zip.forEach((filename, file) => { - const url = Resource.root + 'min/' + filename + let cache = {} + const files = zip.file(/.+/) + for (const file of files) { + const url = Resource.root + 'min/' + file.name const resource = Object.values(Resource.all).find(it => it.rawUrl === url) - if (resource) { - file.async('text').then(text => { - settings.cache = Object.assign(settings.cache, { - [resource.key]: text - }) - // getHash(text).then(hash => console.log(`full download: saved ${resource.key} (${hash})`)) - console.log(`bundle update: saved ${resource.key}`) - }) + if (resource && !resource.alwaysPreview) { + const text = await file.async('text') + cache[resource.key] = text + console.log(`bundle update: saved ${resource.key}`) } - }) + } + settings.cache = Object.assign(settings.cache, cache) // } else { // const hashJson = await Ajax.monkey({ // url: Resource.root + 'min/bundle.json', diff --git a/bilibili-evolved.user.js b/bilibili-evolved.user.js index 712843639..cc2706ee9 100644 --- a/bilibili-evolved.user.js +++ b/bilibili-evolved.user.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved -// @version 1.9.1 +// @version 1.9.2 // @description 强大的哔哩哔哩增强脚本: 下载视频, 音乐, 封面, 弹幕 / 自定义播放器画质, 模式, 布局 / 自定义顶栏, 删除广告, 夜间模式 / 触屏设备支持 // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) @@ -1202,12 +1202,24 @@ class Resource { console.log(`hit cache: ${key}`) resolve(cache) } else { - this.text = onlineData[this.rawUrl] - console.log(`load online data: ${key}`) - settings.cache = Object.assign(settings.cache, { - [key]: this.text - }) - resolve(this.text) + this.text = onlineData[this.url] + // settings.cache = Object.assign(settings.cache, { + // [key]: this.text + // }) + if (text) { + console.log(`load online data: ${key}`) + resolve(this.text) + } else { + Ajax.monkey({ url: this.url }) + .then(text => { + this.text = text + settings.cache = Object.assign(settings.cache, { + [key]: text + }) + resolve(this.text) + }) + .catch(error => reject(error)) + } } } else { Ajax.monkey({ url: this.url }) @@ -2257,19 +2269,18 @@ class ResourceManager { url, responseType: 'blob', })) - zip.forEach((filename, file) => { - const url = Resource.root + 'min/' + filename + let cache = {} + const files = zip.file(/.+/) + for (const file of files) { + const url = Resource.root + 'min/' + file.name const resource = Object.values(Resource.all).find(it => it.rawUrl === url) - if (resource) { - file.async('text').then(text => { - settings.cache = Object.assign(settings.cache, { - [resource.key]: text - }) - // getHash(text).then(hash => console.log(`full download: saved ${resource.key} (${hash})`)) - console.log(`bundle update: saved ${resource.key}`) - }) + if (resource && !resource.alwaysPreview) { + const text = await file.async('text') + cache[resource.key] = text + console.log(`bundle update: saved ${resource.key}`) } - }) + } + settings.cache = Object.assign(settings.cache, cache) // } else { // const hashJson = await Ajax.monkey({ // url: Resource.root + 'min/bundle.json', diff --git a/builder/dotnet/BundleBuilder.cs b/builder/dotnet/BundleBuilder.cs index 819d6b0db..df102a9c9 100644 --- a/builder/dotnet/BundleBuilder.cs +++ b/builder/dotnet/BundleBuilder.cs @@ -39,7 +39,7 @@ namespace BilibiliEvolved.Build { var filename = Path.GetFileName(url); var hash = string.Join("", sha256.ComputeHash(File.OpenRead(url)).Select(b => b.ToString("X2")).ToArray()); - zip.CreateEntryFromFile(url, filename); + zip.CreateEntryFromFile(url, filename, CompressionLevel.NoCompression); hashDict.Add(filename, hash); } } diff --git a/builder/dotnet/publish/build.dll b/builder/dotnet/publish/build.dll index e7aa71d3c..e4496be75 100644 Binary files a/builder/dotnet/publish/build.dll and b/builder/dotnet/publish/build.dll differ diff --git a/min/bundle.zip b/min/bundle.zip index 54000f37e..16305c1a9 100644 Binary files a/min/bundle.zip and b/min/bundle.zip differ diff --git a/src/client/bilibili-evolved.js b/src/client/bilibili-evolved.js index 6a76f06ca..7cb7aeea7 100644 --- a/src/client/bilibili-evolved.js +++ b/src/client/bilibili-evolved.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Bilibili Evolved (Preview) -// @version 1.9.1 +// @version 1.9.2 // @description Bilibili Evolved 的预览版, 可以抢先体验新功能. // @author Grant Howard, Coulomb-G // @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G) diff --git a/src/client/resource-manager.js b/src/client/resource-manager.js index b10b00fa5..91d48bef4 100644 --- a/src/client/resource-manager.js +++ b/src/client/resource-manager.js @@ -244,19 +244,18 @@ export class ResourceManager { url, responseType: 'blob', })) - zip.forEach((filename, file) => { - const url = Resource.root + 'min/' + filename + let cache = {} + const files = zip.file(/.+/) + for (const file of files) { + const url = Resource.root + 'min/' + file.name const resource = Object.values(Resource.all).find(it => it.rawUrl === url) - if (resource) { - file.async('text').then(text => { - settings.cache = Object.assign(settings.cache, { - [resource.key]: text - }) - // getHash(text).then(hash => console.log(`full download: saved ${resource.key} (${hash})`)) - console.log(`bundle update: saved ${resource.key}`) - }) + if (resource && !resource.alwaysPreview) { + const text = await file.async('text') + cache[resource.key] = text + console.log(`bundle update: saved ${resource.key}`) } - }) + } + settings.cache = Object.assign(settings.cache, cache) // } else { // const hashJson = await Ajax.monkey({ // url: Resource.root + 'min/bundle.json', diff --git a/src/client/resource.js b/src/client/resource.js index 58a535f13..b676ef219 100644 --- a/src/client/resource.js +++ b/src/client/resource.js @@ -59,12 +59,24 @@ export class Resource { console.log(`hit cache: ${key}`) resolve(cache) } else { - this.text = onlineData[this.rawUrl] - console.log(`load online data: ${key}`) - settings.cache = Object.assign(settings.cache, { - [key]: this.text - }) - resolve(this.text) + this.text = onlineData[this.url] + // settings.cache = Object.assign(settings.cache, { + // [key]: this.text + // }) + if (text) { + console.log(`load online data: ${key}`) + resolve(this.text) + } else { + Ajax.monkey({ url: this.url }) + .then(text => { + this.text = text + settings.cache = Object.assign(settings.cache, { + [key]: text + }) + resolve(this.text) + }) + .catch(error => reject(error)) + } } } else { Ajax.monkey({ url: this.url }) diff --git a/version.txt b/version.txt index ee672d89a..6f2d3653d 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.9.1 \ No newline at end of file +1.9.2 \ No newline at end of file