This commit is contained in:
the1812 2019-09-03 11:15:19 +08:00
parent dfc12a00cd
commit b80a7ad63f
8 changed files with 31 additions and 66 deletions

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved (Offline)
// @version 413.79
// @version 413.81
// @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中.
// @author Grant Howard, Coulomb-G
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
@ -2227,14 +2227,10 @@ class ResourceManager {
url,
responseType: 'blob',
}))
console.log('zip: ', zip)
zip.forEach((filename, file) => {
const url = Resource.root + 'min/' + filename
const resource = Object.values(Resource.all).find(it => it.rawUrl === url)
if (resource) {
console.log('url: ', url)
console.log('resource: ', resource)
console.log('file: ', file)
file.async('text').then(text => {
settings.cache = Object.assign(settings.cache, {
[resource.key]: text
@ -2247,7 +2243,6 @@ class ResourceManager {
url: Resource.root + 'min/bundle.json',
responseType: 'json',
})
console.log('hashJson: ', hashJson)
await Promise.all(Object.entries(hashJson).map(async ([name, hash]) => {
const url = Resource.root + 'min/' + name
const resource = Object.values(Resource.all).find(it => it.rawUrl === url)
@ -2265,15 +2260,13 @@ class ResourceManager {
return hashHex
}
const cacheHash = await getHash(cache)
if (cacheHash.toLowerCase() === hash.toLowerCase()) {
return
if (cacheHash.toLowerCase() !== hash.toLowerCase()) {
await resource.download()
settings.cache = Object.assign(settings.cache, {
[resource.key]: resource.text
})
}
}
console.log(`loading ${resource.key}`)
await resource.download()
settings.cache = Object.assign(settings.cache, {
[resource.key]: resource.text
})
}))
}

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved (Preview Offline)
// @version 413.79
// @version 413.81
// @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中.
// @author Grant Howard, Coulomb-G
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
@ -2227,14 +2227,10 @@ class ResourceManager {
url,
responseType: 'blob',
}))
console.log('zip: ', zip)
zip.forEach((filename, file) => {
const url = Resource.root + 'min/' + filename
const resource = Object.values(Resource.all).find(it => it.rawUrl === url)
if (resource) {
console.log('url: ', url)
console.log('resource: ', resource)
console.log('file: ', file)
file.async('text').then(text => {
settings.cache = Object.assign(settings.cache, {
[resource.key]: text
@ -2247,7 +2243,6 @@ class ResourceManager {
url: Resource.root + 'min/bundle.json',
responseType: 'json',
})
console.log('hashJson: ', hashJson)
await Promise.all(Object.entries(hashJson).map(async ([name, hash]) => {
const url = Resource.root + 'min/' + name
const resource = Object.values(Resource.all).find(it => it.rawUrl === url)
@ -2265,15 +2260,13 @@ class ResourceManager {
return hashHex
}
const cacheHash = await getHash(cache)
if (cacheHash.toLowerCase() === hash.toLowerCase()) {
return
if (cacheHash.toLowerCase() !== hash.toLowerCase()) {
await resource.download()
settings.cache = Object.assign(settings.cache, {
[resource.key]: resource.text
})
}
}
console.log(`loading ${resource.key}`)
await resource.download()
settings.cache = Object.assign(settings.cache, {
[resource.key]: resource.text
})
}))
}

View File

@ -2247,14 +2247,10 @@ class ResourceManager {
url,
responseType: 'blob',
}))
console.log('zip: ', zip)
zip.forEach((filename, file) => {
const url = Resource.root + 'min/' + filename
const resource = Object.values(Resource.all).find(it => it.rawUrl === url)
if (resource) {
console.log('url: ', url)
console.log('resource: ', resource)
console.log('file: ', file)
file.async('text').then(text => {
settings.cache = Object.assign(settings.cache, {
[resource.key]: text
@ -2267,7 +2263,6 @@ class ResourceManager {
url: Resource.root + 'min/bundle.json',
responseType: 'json',
})
console.log('hashJson: ', hashJson)
await Promise.all(Object.entries(hashJson).map(async ([name, hash]) => {
const url = Resource.root + 'min/' + name
const resource = Object.values(Resource.all).find(it => it.rawUrl === url)
@ -2285,15 +2280,13 @@ class ResourceManager {
return hashHex
}
const cacheHash = await getHash(cache)
if (cacheHash.toLowerCase() === hash.toLowerCase()) {
return
if (cacheHash.toLowerCase() !== hash.toLowerCase()) {
await resource.download()
settings.cache = Object.assign(settings.cache, {
[resource.key]: resource.text
})
}
}
console.log(`loading ${resource.key}`)
await resource.download()
settings.cache = Object.assign(settings.cache, {
[resource.key]: resource.text
})
}))
}

View File

@ -2247,14 +2247,10 @@ class ResourceManager {
url,
responseType: 'blob',
}))
console.log('zip: ', zip)
zip.forEach((filename, file) => {
const url = Resource.root + 'min/' + filename
const resource = Object.values(Resource.all).find(it => it.rawUrl === url)
if (resource) {
console.log('url: ', url)
console.log('resource: ', resource)
console.log('file: ', file)
file.async('text').then(text => {
settings.cache = Object.assign(settings.cache, {
[resource.key]: text
@ -2267,7 +2263,6 @@ class ResourceManager {
url: Resource.root + 'min/bundle.json',
responseType: 'json',
})
console.log('hashJson: ', hashJson)
await Promise.all(Object.entries(hashJson).map(async ([name, hash]) => {
const url = Resource.root + 'min/' + name
const resource = Object.values(Resource.all).find(it => it.rawUrl === url)
@ -2285,15 +2280,13 @@ class ResourceManager {
return hashHex
}
const cacheHash = await getHash(cache)
if (cacheHash.toLowerCase() === hash.toLowerCase()) {
return
if (cacheHash.toLowerCase() !== hash.toLowerCase()) {
await resource.download()
settings.cache = Object.assign(settings.cache, {
[resource.key]: resource.text
})
}
}
console.log(`loading ${resource.key}`)
await resource.download()
settings.cache = Object.assign(settings.cache, {
[resource.key]: resource.text
})
}))
}

View File

@ -20,10 +20,10 @@ namespace BilibiliEvolved.Build
select file.Replace(@"\", "/");
var hashDict = new Dictionary<string, string>();
var zipName = "min/bundle.zip";
// if (File.Exists(zipName))
// {
// File.Delete(zipName);
// }
if (File.Exists(zipName))
{
File.Delete(zipName);
}
using (var sha256 = new SHA256Managed())
using (var zip = ZipFile.Open(zipName, ZipArchiveMode.Update))
{

Binary file not shown.

Binary file not shown.

View File

@ -215,14 +215,10 @@ export class ResourceManager {
url,
responseType: 'blob',
}))
console.log('zip: ', zip)
zip.forEach((filename, file) => {
const url = Resource.root + 'min/' + filename
const resource = Object.values(Resource.all).find(it => it.rawUrl === url)
if (resource) {
console.log('url: ', url)
console.log('resource: ', resource)
console.log('file: ', file)
file.async('text').then(text => {
settings.cache = Object.assign(settings.cache, {
[resource.key]: text
@ -235,7 +231,6 @@ export class ResourceManager {
url: Resource.root + 'min/bundle.json',
responseType: 'json',
})
console.log('hashJson: ', hashJson)
await Promise.all(Object.entries(hashJson).map(async ([name, hash]) => {
const url = Resource.root + 'min/' + name
const resource = Object.values(Resource.all).find(it => it.rawUrl === url)
@ -253,15 +248,13 @@ export class ResourceManager {
return hashHex
}
const cacheHash = await getHash(cache)
if (cacheHash.toLowerCase() === hash.toLowerCase()) {
return
if (cacheHash.toLowerCase() !== hash.toLowerCase()) {
await resource.download()
settings.cache = Object.assign(settings.cache, {
[resource.key]: resource.text
})
}
}
console.log(`loading ${resource.key}`)
await resource.download()
settings.cache = Object.assign(settings.cache, {
[resource.key]: resource.text
})
}))
}