mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Update metadata
This commit is contained in:
parent
86f96caae8
commit
78ea139b72
104
dist/bilibili-evolved.preview.user.js
vendored
Normal file
104
dist/bilibili-evolved.preview.user.js
vendored
Normal file
File diff suppressed because one or more lines are too long
104
dist/bilibili-evolved.user.js
vendored
Normal file
104
dist/bilibili-evolved.user.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"name": "Bilibili Evolved (v2)",
|
"name": "Bilibili Evolved",
|
||||||
"description": "强大的哔哩哔哩增强脚本",
|
"description": "强大的哔哩哔哩增强脚本",
|
||||||
"updateURL": "https://cdn.jsdelivr.net/gh/the1812/Bilibili-Evolved@master/dist/bilibili-evolved.user.js",
|
"updateURL": "https://cdn.jsdelivr.net/gh/the1812/Bilibili-Evolved@master/dist/bilibili-evolved.user.js",
|
||||||
"downloadURL": "https://cdn.jsdelivr.net/gh/the1812/Bilibili-Evolved@master/dist/bilibili-evolved.user.js"
|
"downloadURL": "https://cdn.jsdelivr.net/gh/the1812/Bilibili-Evolved@master/dist/bilibili-evolved.user.js"
|
||||||
|
|||||||
@ -1,48 +0,0 @@
|
|||||||
import { meta, defaultBranch } from './meta'
|
|
||||||
import { monkey } from './ajax'
|
|
||||||
import { Version } from './version'
|
|
||||||
import { settings } from './settings'
|
|
||||||
import { fullyLoaded } from './life-cycle'
|
|
||||||
|
|
||||||
const checkVersionUpdate = (update: PackageUpdate) => {
|
|
||||||
const version = new Version(update.meta.version)
|
|
||||||
const current = new Version(meta.version)
|
|
||||||
if (version.greaterThan(current)) {
|
|
||||||
console.log(`New version available: v${update.meta.version}`)
|
|
||||||
// TODO: notify new version
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
const installPackageUpdate = (packageCodes: string) => {
|
|
||||||
settings.update = packageCodes
|
|
||||||
}
|
|
||||||
export const checkUpdate = (() => {
|
|
||||||
const update = async () => {
|
|
||||||
console.log('Checking for update...')
|
|
||||||
const { getGeneralSettings } = await import('./settings')
|
|
||||||
const { cdnRoots } = await import('./cdn-types')
|
|
||||||
const { cdnRoot } = getGeneralSettings()
|
|
||||||
const updateUrl = `${cdnRoots[cdnRoot]}dist/package.js`
|
|
||||||
const packageCodes = await monkey({
|
|
||||||
url: updateUrl,
|
|
||||||
})
|
|
||||||
eval(packageCodes)
|
|
||||||
const updatePackage = window.bilibiliEvolvedUpdate
|
|
||||||
if (checkVersionUpdate(updatePackage)) { // 检查版本, 有新版本时不再进行组件更新
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (meta.branch === defaultBranch) { // 主分支需要安装组件更新
|
|
||||||
installPackageUpdate(packageCodes)
|
|
||||||
console.log('Installed package update.')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return () => {
|
|
||||||
// Violentmonkey 不兼容 requestIdleCallback
|
|
||||||
if ('requestIdleCallback' in unsafeWindow && GM_info.scriptHandler !== 'Violentmonkey') {
|
|
||||||
unsafeWindow.requestIdleCallback(update)
|
|
||||||
} else {
|
|
||||||
fullyLoaded(update)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})()
|
|
||||||
Loading…
Reference in New Issue
Block a user