mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Fix update url (fix #3122)
This commit is contained in:
parent
0b45a3862c
commit
2ef5779b41
@ -1,3 +1,4 @@
|
||||
import { cdnRoots } from '@/core/cdn-types'
|
||||
import { ComponentMetadata, componentsTags } from '../types'
|
||||
|
||||
export const component: ComponentMetadata = {
|
||||
@ -24,15 +25,17 @@ export const component: ComponentMetadata = {
|
||||
const { monkey } = await import('@/core/ajax')
|
||||
const { meta } = await import('@/core/meta')
|
||||
const { Toast } = await import('@/core/toast')
|
||||
const { getGeneralSettings } = await import('@/core/settings')
|
||||
const now = Number(new Date())
|
||||
const duration = now - options.lastUpdateCheck
|
||||
if (duration < options.minimumDuration) { // 未到间隔期
|
||||
return
|
||||
}
|
||||
const updateUrl = GM_info.scriptUpdateURL
|
||||
if (!updateUrl) { // 本地调试版没有 updateUrl
|
||||
// 本地调试版不检查
|
||||
if (!GM_info.scriptUpdateURL) {
|
||||
return
|
||||
}
|
||||
const updateUrl = `${cdnRoots[getGeneralSettings().cdnRoot](meta.compilationInfo.branch)}dist/${meta.originalFilename}`
|
||||
const scriptText: string = await monkey({ url: updateUrl, responseType: 'text' })
|
||||
options.lastUpdateCheck = Number(new Date())
|
||||
const versionMatch = scriptText.match(/^\/\/ @version\s*([\d\.]+)$/m)
|
||||
|
||||
@ -24,7 +24,7 @@ export const meta = {
|
||||
if (branch === branches.stable) {
|
||||
return 'bilibili-evolved.user.js'
|
||||
}
|
||||
return `bilibili-evolved.${branch}.user.js`
|
||||
return `bilibili-evolved.${branches.preview}.user.js`
|
||||
},
|
||||
/** 检查更新的链接 */
|
||||
get updateURL(): string {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user