Fix alway-preview resources

This commit is contained in:
the1812 2019-09-08 10:45:37 +08:00
parent ffbff7132b
commit 260508b00a
11 changed files with 111 additions and 80 deletions

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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',

View File

@ -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);
}
}

Binary file not shown.

Binary file not shown.

View File

@ -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)

View File

@ -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',

View File

@ -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 })

View File

@ -1 +1 @@
1.9.1
1.9.2