mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Add more logs
This commit is contained in:
parent
7bfd07393c
commit
7fd549dd98
@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name Bilibili Evolved (Offline)
|
||||
// @version 416.09
|
||||
// @version 416.10
|
||||
// @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中.
|
||||
// @author Grant Howard, Coulomb-G
|
||||
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
|
||||
@ -2206,6 +2206,14 @@ class ResourceManager {
|
||||
if (isOffline()) {
|
||||
return
|
||||
}
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
const getHash = async (message) => {
|
||||
const msgUint8 = new TextEncoder().encode(message)
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
return hashHex
|
||||
}
|
||||
if (fullDownload) {
|
||||
const url = Resource.root + 'min/bundle.zip'
|
||||
const zip = new JSZip()
|
||||
@ -2221,6 +2229,7 @@ class ResourceManager {
|
||||
settings.cache = Object.assign(settings.cache, {
|
||||
[resource.key]: text
|
||||
})
|
||||
getHash(text).then(hash => console.log(`full download: saved ${resource.key} (${hash})`))
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -2237,22 +2246,14 @@ class ResourceManager {
|
||||
}
|
||||
const cache = settings.cache[resource.key]
|
||||
if (cache) {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
const getHash = async (message) => {
|
||||
const msgUint8 = new TextEncoder().encode(message)
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
return hashHex
|
||||
}
|
||||
const cacheHash = await getHash(cache)
|
||||
if (cacheHash.toLowerCase() !== hash.toLowerCase()) {
|
||||
console.log(`hash not match: ${resource.key}`)
|
||||
console.log(`hash not match: ${resource.key} (${cacheHash.toLowerCase()}) !== (${hash.toLowerCase()})`)
|
||||
await resource.download()
|
||||
settings.cache = Object.assign(settings.cache, {
|
||||
[resource.key]: resource.text
|
||||
})
|
||||
console.log(`downloaded ${resource.key} (${await getHash(settings.cache[resource.key])})`)
|
||||
console.log(`downloaded ${resource.key} (${await getHash(resource.text)}) => (${await getHash(settings.cache[resource.key])})`)
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// ==UserScript==
|
||||
// @name Bilibili Evolved (Preview Offline)
|
||||
// @version 416.09
|
||||
// @version 416.10
|
||||
// @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中.
|
||||
// @author Grant Howard, Coulomb-G
|
||||
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
|
||||
@ -2206,6 +2206,14 @@ class ResourceManager {
|
||||
if (isOffline()) {
|
||||
return
|
||||
}
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
const getHash = async (message) => {
|
||||
const msgUint8 = new TextEncoder().encode(message)
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
return hashHex
|
||||
}
|
||||
if (fullDownload) {
|
||||
const url = Resource.root + 'min/bundle.zip'
|
||||
const zip = new JSZip()
|
||||
@ -2221,6 +2229,7 @@ class ResourceManager {
|
||||
settings.cache = Object.assign(settings.cache, {
|
||||
[resource.key]: text
|
||||
})
|
||||
getHash(text).then(hash => console.log(`full download: saved ${resource.key} (${hash})`))
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -2237,22 +2246,14 @@ class ResourceManager {
|
||||
}
|
||||
const cache = settings.cache[resource.key]
|
||||
if (cache) {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
const getHash = async (message) => {
|
||||
const msgUint8 = new TextEncoder().encode(message)
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
return hashHex
|
||||
}
|
||||
const cacheHash = await getHash(cache)
|
||||
if (cacheHash.toLowerCase() !== hash.toLowerCase()) {
|
||||
console.log(`hash not match: ${resource.key}`)
|
||||
console.log(`hash not match: ${resource.key} (${cacheHash.toLowerCase()}) !== (${hash.toLowerCase()})`)
|
||||
await resource.download()
|
||||
settings.cache = Object.assign(settings.cache, {
|
||||
[resource.key]: resource.text
|
||||
})
|
||||
console.log(`downloaded ${resource.key} (${await getHash(settings.cache[resource.key])})`)
|
||||
console.log(`downloaded ${resource.key} (${await getHash(resource.text)}) => (${await getHash(settings.cache[resource.key])})`)
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
@ -2226,6 +2226,14 @@ class ResourceManager {
|
||||
if (isOffline()) {
|
||||
return
|
||||
}
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
const getHash = async (message) => {
|
||||
const msgUint8 = new TextEncoder().encode(message)
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
return hashHex
|
||||
}
|
||||
if (fullDownload) {
|
||||
const url = Resource.root + 'min/bundle.zip'
|
||||
const zip = new JSZip()
|
||||
@ -2241,6 +2249,7 @@ class ResourceManager {
|
||||
settings.cache = Object.assign(settings.cache, {
|
||||
[resource.key]: text
|
||||
})
|
||||
getHash(text).then(hash => console.log(`full download: saved ${resource.key} (${hash})`))
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -2257,22 +2266,14 @@ class ResourceManager {
|
||||
}
|
||||
const cache = settings.cache[resource.key]
|
||||
if (cache) {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
const getHash = async (message) => {
|
||||
const msgUint8 = new TextEncoder().encode(message)
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
return hashHex
|
||||
}
|
||||
const cacheHash = await getHash(cache)
|
||||
if (cacheHash.toLowerCase() !== hash.toLowerCase()) {
|
||||
console.log(`hash not match: ${resource.key}`)
|
||||
console.log(`hash not match: ${resource.key} (${cacheHash.toLowerCase()}) !== (${hash.toLowerCase()})`)
|
||||
await resource.download()
|
||||
settings.cache = Object.assign(settings.cache, {
|
||||
[resource.key]: resource.text
|
||||
})
|
||||
console.log(`downloaded ${resource.key} (${await getHash(settings.cache[resource.key])})`)
|
||||
console.log(`downloaded ${resource.key} (${await getHash(resource.text)}) => (${await getHash(settings.cache[resource.key])})`)
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
@ -2226,6 +2226,14 @@ class ResourceManager {
|
||||
if (isOffline()) {
|
||||
return
|
||||
}
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
const getHash = async (message) => {
|
||||
const msgUint8 = new TextEncoder().encode(message)
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
return hashHex
|
||||
}
|
||||
if (fullDownload) {
|
||||
const url = Resource.root + 'min/bundle.zip'
|
||||
const zip = new JSZip()
|
||||
@ -2241,6 +2249,7 @@ class ResourceManager {
|
||||
settings.cache = Object.assign(settings.cache, {
|
||||
[resource.key]: text
|
||||
})
|
||||
getHash(text).then(hash => console.log(`full download: saved ${resource.key} (${hash})`))
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -2257,22 +2266,14 @@ class ResourceManager {
|
||||
}
|
||||
const cache = settings.cache[resource.key]
|
||||
if (cache) {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
const getHash = async (message) => {
|
||||
const msgUint8 = new TextEncoder().encode(message)
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
return hashHex
|
||||
}
|
||||
const cacheHash = await getHash(cache)
|
||||
if (cacheHash.toLowerCase() !== hash.toLowerCase()) {
|
||||
console.log(`hash not match: ${resource.key}`)
|
||||
console.log(`hash not match: ${resource.key} (${cacheHash.toLowerCase()}) !== (${hash.toLowerCase()})`)
|
||||
await resource.download()
|
||||
settings.cache = Object.assign(settings.cache, {
|
||||
[resource.key]: resource.text
|
||||
})
|
||||
console.log(`downloaded ${resource.key} (${await getHash(settings.cache[resource.key])})`)
|
||||
console.log(`downloaded ${resource.key} (${await getHash(resource.text)}) => (${await getHash(settings.cache[resource.key])})`)
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
BIN
min/bundle.zip
BIN
min/bundle.zip
Binary file not shown.
@ -219,6 +219,14 @@ export class ResourceManager {
|
||||
if (isOffline()) {
|
||||
return
|
||||
}
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
const getHash = async (message) => {
|
||||
const msgUint8 = new TextEncoder().encode(message)
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
return hashHex
|
||||
}
|
||||
if (fullDownload) {
|
||||
const url = Resource.root + 'min/bundle.zip'
|
||||
const zip = new JSZip()
|
||||
@ -234,6 +242,7 @@ export class ResourceManager {
|
||||
settings.cache = Object.assign(settings.cache, {
|
||||
[resource.key]: text
|
||||
})
|
||||
getHash(text).then(hash => console.log(`full download: saved ${resource.key} (${hash})`))
|
||||
})
|
||||
}
|
||||
})
|
||||
@ -250,22 +259,14 @@ export class ResourceManager {
|
||||
}
|
||||
const cache = settings.cache[resource.key]
|
||||
if (cache) {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest
|
||||
const getHash = async (message) => {
|
||||
const msgUint8 = new TextEncoder().encode(message)
|
||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
|
||||
return hashHex
|
||||
}
|
||||
const cacheHash = await getHash(cache)
|
||||
if (cacheHash.toLowerCase() !== hash.toLowerCase()) {
|
||||
console.log(`hash not match: ${resource.key}`)
|
||||
console.log(`hash not match: ${resource.key} (${cacheHash.toLowerCase()}) !== (${hash.toLowerCase()})`)
|
||||
await resource.download()
|
||||
settings.cache = Object.assign(settings.cache, {
|
||||
[resource.key]: resource.text
|
||||
})
|
||||
console.log(`downloaded ${resource.key} (${await getHash(settings.cache[resource.key])})`)
|
||||
console.log(`downloaded ${resource.key} (${await getHash(resource.text)}) => (${await getHash(settings.cache[resource.key])})`)
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
Loading…
Reference in New Issue
Block a user