From 1f8569b89c034ddeff96ae6137693d587403425f Mon Sep 17 00:00:00 2001 From: the1812 Date: Wed, 25 Sep 2019 14:55:32 +0800 Subject: [PATCH] Refactor reloadables manifest --- bilibili-evolved.offline.user.js | 66 ++++++++++++++++-------- bilibili-evolved.preview-offline.user.js | 66 ++++++++++++++++-------- bilibili-evolved.preview.user.js | 66 ++++++++++++++++-------- bilibili-evolved.user.js | 66 ++++++++++++++++-------- src/client/resource-loader.js | 46 +++++++++-------- src/client/resource-manifest.js | 20 +++++++ 6 files changed, 225 insertions(+), 105 deletions(-) diff --git a/bilibili-evolved.offline.user.js b/bilibili-evolved.offline.user.js index 13384a48e..1c03908dc 100644 --- a/bilibili-evolved.offline.user.js +++ b/bilibili-evolved.offline.user.js @@ -573,31 +573,35 @@ function loadResources () { Resource.root = 'https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/' Resource.all = {} Resource.displayNames = {} - Resource.reloadables = [ - 'useDarkStyle', - 'hideBanner', - 'customNavbar', - 'playerShadow', - 'narrowDanmaku', - 'compactLayout', - 'useCommentStyle', - 'removeVideoTopMask', - 'hideOldEntry', - 'hideBangumiReviews', - 'videoScreenshot', - 'blurVideoControl', - 'customControlBackground', - 'harunaScale', - 'removeLiveWatermark', - 'framePlayback', - 'hideCategory', - 'fullTweetsTitle', - 'fullActivityContent', - ] + // Resource.reloadables = [ + // 'useDarkStyle', + // 'hideBanner', + // 'customNavbar', + // 'playerShadow', + // 'narrowDanmaku', + // 'compactLayout', + // 'useCommentStyle', + // 'removeVideoTopMask', + // 'hideOldEntry', + // 'hideBangumiReviews', + // 'videoScreenshot', + // 'blurVideoControl', + // 'customControlBackground', + // 'harunaScale', + // 'removeLiveWatermark', + // 'framePlayback', + // 'hideCategory', + // 'fullTweetsTitle', + // 'fullActivityContent', + // ] + Resource.reloadables = [] for (const [key, data] of Object.entries(Resource.manifest)) { const resource = new Resource(data.path, { styles: data.styles, alwaysPreview: data.alwaysPreview }) resource.key = key resource.dropdown = data.dropdown + if (data.reloadable) { + Resource.reloadables.push(key) + } if (data.displayNames) { resource.displayName = data.displayNames[key] Object.assign(Resource.displayNames, data.displayNames) @@ -1399,6 +1403,7 @@ Resource.manifest = { }, useDarkStyle: { path: 'dark-styles.min.js', + reloadable: true, alwaysPreview: true, styles: [ 'darkStyle', @@ -1446,6 +1451,7 @@ Resource.manifest = { }, hideBanner: { path: 'hide-banner.min.js', + reloadable: true, style: 'instant', displayNames: { hideBanner: '隐藏顶部横幅' @@ -1496,18 +1502,21 @@ Resource.manifest = { }, harunaScale: { path: 'haruna-scale.min.js', + reloadable: true, displayNames: { harunaScale: '缩放直播看板娘' } }, removeLiveWatermark: { path: 'remove-watermark.min.js', + reloadable: true, displayNames: { removeLiveWatermark: '删除直播水印' } }, fullTweetsTitle: { path: 'full-tweets-title.min.js', + reloadable: true, style: 'instant', displayNames: { fullTweetsTitle: '展开动态标题' @@ -1550,12 +1559,14 @@ Resource.manifest = { }, removeVideoTopMask: { path: 'remove-top-mask.min.js', + reloadable: true, displayNames: { removeVideoTopMask: '删除视频标题层' } }, blurVideoControl: { path: 'blur-video-control.min.js', + reloadable: true, style: 'instant', displayNames: { blurVideoControl: '模糊视频控制栏背景' @@ -1617,6 +1628,7 @@ Resource.manifest = { }, customControlBackground: { path: 'custom-control-background.min.js', + reloadable: true, style: { key: 'customControlBackgroundStyle', condition: () => settings.customControlBackgroundOpacity > 0 @@ -1714,6 +1726,7 @@ Resource.manifest = { }, compactLayout: { path: 'compact-layout.min.js', + reloadable: true, style: true, displayNames: { compactLayout: '首页使用紧凑布局' @@ -1747,6 +1760,7 @@ Resource.manifest = { }, useCommentStyle: { path: 'comment.min.js', + reloadable: true, style: 'important', displayNames: { useCommentStyle: '简化评论区' @@ -1772,6 +1786,7 @@ Resource.manifest = { }, framePlayback: { path: 'frame-playback.min.js', + reloadable: true, style: 'instant', html: true, displayNames: { @@ -1836,6 +1851,7 @@ Resource.manifest = { }, customNavbar: { path: 'custom-navbar.min.js', + reloadable: true, style: 'instant', html: true, displayNames: { @@ -1864,24 +1880,28 @@ Resource.manifest = { }, playerShadow: { path: 'player-shadow.min.js', + reloadable: true, displayNames: { playerShadow: '播放器投影' } }, narrowDanmaku: { path: 'narrow-danmaku.min.js', + reloadable: true, displayNames: { narrowDanmaku: '强制保留弹幕栏' } }, hideOldEntry: { path: 'hide-old-entry.min.js', + reloadable: true, displayNames: { hideOldEntry: '隐藏返回旧版' } }, videoScreenshot: { path: 'screenshot.min.js', + reloadable: true, style: true, displayNames: { videoScreenshot: '启用视频截图' @@ -1892,6 +1912,7 @@ Resource.manifest = { }, hideBangumiReviews: { path: 'hide-bangumi-reviews.min.js', + reloadable: true, displayNames: { hideBangumiReviews: '隐藏番剧点评' } @@ -1911,6 +1932,7 @@ Resource.manifest = { }, hideCategory: { path: 'hide-category.min.js', + reloadable: true, style: 'instant', displayNames: { hideCategory: '隐藏分区栏', @@ -1974,6 +1996,7 @@ Resource.manifest = { }, fullActivityContent: { path: 'full-activity-content.min.js', + reloadable: true, displayNames: { fullActivityContent: '展开动态内容', }, @@ -1986,6 +2009,7 @@ Resource.manifest = { }, selectableColumnText: { path: 'selectable-column-text.min.js', + reloadable: true, displayNames: { selectableColumnText: '专栏文字选择', }, diff --git a/bilibili-evolved.preview-offline.user.js b/bilibili-evolved.preview-offline.user.js index 884e62481..0d088f234 100644 --- a/bilibili-evolved.preview-offline.user.js +++ b/bilibili-evolved.preview-offline.user.js @@ -573,31 +573,35 @@ function loadResources () { Resource.root = 'https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/' Resource.all = {} Resource.displayNames = {} - Resource.reloadables = [ - 'useDarkStyle', - 'hideBanner', - 'customNavbar', - 'playerShadow', - 'narrowDanmaku', - 'compactLayout', - 'useCommentStyle', - 'removeVideoTopMask', - 'hideOldEntry', - 'hideBangumiReviews', - 'videoScreenshot', - 'blurVideoControl', - 'customControlBackground', - 'harunaScale', - 'removeLiveWatermark', - 'framePlayback', - 'hideCategory', - 'fullTweetsTitle', - 'fullActivityContent', - ] + // Resource.reloadables = [ + // 'useDarkStyle', + // 'hideBanner', + // 'customNavbar', + // 'playerShadow', + // 'narrowDanmaku', + // 'compactLayout', + // 'useCommentStyle', + // 'removeVideoTopMask', + // 'hideOldEntry', + // 'hideBangumiReviews', + // 'videoScreenshot', + // 'blurVideoControl', + // 'customControlBackground', + // 'harunaScale', + // 'removeLiveWatermark', + // 'framePlayback', + // 'hideCategory', + // 'fullTweetsTitle', + // 'fullActivityContent', + // ] + Resource.reloadables = [] for (const [key, data] of Object.entries(Resource.manifest)) { const resource = new Resource(data.path, { styles: data.styles, alwaysPreview: data.alwaysPreview }) resource.key = key resource.dropdown = data.dropdown + if (data.reloadable) { + Resource.reloadables.push(key) + } if (data.displayNames) { resource.displayName = data.displayNames[key] Object.assign(Resource.displayNames, data.displayNames) @@ -1399,6 +1403,7 @@ Resource.manifest = { }, useDarkStyle: { path: 'dark-styles.min.js', + reloadable: true, alwaysPreview: true, styles: [ 'darkStyle', @@ -1446,6 +1451,7 @@ Resource.manifest = { }, hideBanner: { path: 'hide-banner.min.js', + reloadable: true, style: 'instant', displayNames: { hideBanner: '隐藏顶部横幅' @@ -1496,18 +1502,21 @@ Resource.manifest = { }, harunaScale: { path: 'haruna-scale.min.js', + reloadable: true, displayNames: { harunaScale: '缩放直播看板娘' } }, removeLiveWatermark: { path: 'remove-watermark.min.js', + reloadable: true, displayNames: { removeLiveWatermark: '删除直播水印' } }, fullTweetsTitle: { path: 'full-tweets-title.min.js', + reloadable: true, style: 'instant', displayNames: { fullTweetsTitle: '展开动态标题' @@ -1550,12 +1559,14 @@ Resource.manifest = { }, removeVideoTopMask: { path: 'remove-top-mask.min.js', + reloadable: true, displayNames: { removeVideoTopMask: '删除视频标题层' } }, blurVideoControl: { path: 'blur-video-control.min.js', + reloadable: true, style: 'instant', displayNames: { blurVideoControl: '模糊视频控制栏背景' @@ -1617,6 +1628,7 @@ Resource.manifest = { }, customControlBackground: { path: 'custom-control-background.min.js', + reloadable: true, style: { key: 'customControlBackgroundStyle', condition: () => settings.customControlBackgroundOpacity > 0 @@ -1714,6 +1726,7 @@ Resource.manifest = { }, compactLayout: { path: 'compact-layout.min.js', + reloadable: true, style: true, displayNames: { compactLayout: '首页使用紧凑布局' @@ -1747,6 +1760,7 @@ Resource.manifest = { }, useCommentStyle: { path: 'comment.min.js', + reloadable: true, style: 'important', displayNames: { useCommentStyle: '简化评论区' @@ -1772,6 +1786,7 @@ Resource.manifest = { }, framePlayback: { path: 'frame-playback.min.js', + reloadable: true, style: 'instant', html: true, displayNames: { @@ -1836,6 +1851,7 @@ Resource.manifest = { }, customNavbar: { path: 'custom-navbar.min.js', + reloadable: true, style: 'instant', html: true, displayNames: { @@ -1864,24 +1880,28 @@ Resource.manifest = { }, playerShadow: { path: 'player-shadow.min.js', + reloadable: true, displayNames: { playerShadow: '播放器投影' } }, narrowDanmaku: { path: 'narrow-danmaku.min.js', + reloadable: true, displayNames: { narrowDanmaku: '强制保留弹幕栏' } }, hideOldEntry: { path: 'hide-old-entry.min.js', + reloadable: true, displayNames: { hideOldEntry: '隐藏返回旧版' } }, videoScreenshot: { path: 'screenshot.min.js', + reloadable: true, style: true, displayNames: { videoScreenshot: '启用视频截图' @@ -1892,6 +1912,7 @@ Resource.manifest = { }, hideBangumiReviews: { path: 'hide-bangumi-reviews.min.js', + reloadable: true, displayNames: { hideBangumiReviews: '隐藏番剧点评' } @@ -1911,6 +1932,7 @@ Resource.manifest = { }, hideCategory: { path: 'hide-category.min.js', + reloadable: true, style: 'instant', displayNames: { hideCategory: '隐藏分区栏', @@ -1974,6 +1996,7 @@ Resource.manifest = { }, fullActivityContent: { path: 'full-activity-content.min.js', + reloadable: true, displayNames: { fullActivityContent: '展开动态内容', }, @@ -1986,6 +2009,7 @@ Resource.manifest = { }, selectableColumnText: { path: 'selectable-column-text.min.js', + reloadable: true, displayNames: { selectableColumnText: '专栏文字选择', }, diff --git a/bilibili-evolved.preview.user.js b/bilibili-evolved.preview.user.js index c0bf337ad..8f7f063bf 100644 --- a/bilibili-evolved.preview.user.js +++ b/bilibili-evolved.preview.user.js @@ -572,31 +572,35 @@ function loadResources () { Resource.root = 'https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/' Resource.all = {} Resource.displayNames = {} - Resource.reloadables = [ - 'useDarkStyle', - 'hideBanner', - 'customNavbar', - 'playerShadow', - 'narrowDanmaku', - 'compactLayout', - 'useCommentStyle', - 'removeVideoTopMask', - 'hideOldEntry', - 'hideBangumiReviews', - 'videoScreenshot', - 'blurVideoControl', - 'customControlBackground', - 'harunaScale', - 'removeLiveWatermark', - 'framePlayback', - 'hideCategory', - 'fullTweetsTitle', - 'fullActivityContent', - ] + // Resource.reloadables = [ + // 'useDarkStyle', + // 'hideBanner', + // 'customNavbar', + // 'playerShadow', + // 'narrowDanmaku', + // 'compactLayout', + // 'useCommentStyle', + // 'removeVideoTopMask', + // 'hideOldEntry', + // 'hideBangumiReviews', + // 'videoScreenshot', + // 'blurVideoControl', + // 'customControlBackground', + // 'harunaScale', + // 'removeLiveWatermark', + // 'framePlayback', + // 'hideCategory', + // 'fullTweetsTitle', + // 'fullActivityContent', + // ] + Resource.reloadables = [] for (const [key, data] of Object.entries(Resource.manifest)) { const resource = new Resource(data.path, { styles: data.styles, alwaysPreview: data.alwaysPreview }) resource.key = key resource.dropdown = data.dropdown + if (data.reloadable) { + Resource.reloadables.push(key) + } if (data.displayNames) { resource.displayName = data.displayNames[key] Object.assign(Resource.displayNames, data.displayNames) @@ -1452,6 +1456,7 @@ Resource.manifest = { }, useDarkStyle: { path: 'dark-styles.min.js', + reloadable: true, alwaysPreview: true, styles: [ 'darkStyle', @@ -1499,6 +1504,7 @@ Resource.manifest = { }, hideBanner: { path: 'hide-banner.min.js', + reloadable: true, style: 'instant', displayNames: { hideBanner: '隐藏顶部横幅' @@ -1549,18 +1555,21 @@ Resource.manifest = { }, harunaScale: { path: 'haruna-scale.min.js', + reloadable: true, displayNames: { harunaScale: '缩放直播看板娘' } }, removeLiveWatermark: { path: 'remove-watermark.min.js', + reloadable: true, displayNames: { removeLiveWatermark: '删除直播水印' } }, fullTweetsTitle: { path: 'full-tweets-title.min.js', + reloadable: true, style: 'instant', displayNames: { fullTweetsTitle: '展开动态标题' @@ -1603,12 +1612,14 @@ Resource.manifest = { }, removeVideoTopMask: { path: 'remove-top-mask.min.js', + reloadable: true, displayNames: { removeVideoTopMask: '删除视频标题层' } }, blurVideoControl: { path: 'blur-video-control.min.js', + reloadable: true, style: 'instant', displayNames: { blurVideoControl: '模糊视频控制栏背景' @@ -1670,6 +1681,7 @@ Resource.manifest = { }, customControlBackground: { path: 'custom-control-background.min.js', + reloadable: true, style: { key: 'customControlBackgroundStyle', condition: () => settings.customControlBackgroundOpacity > 0 @@ -1767,6 +1779,7 @@ Resource.manifest = { }, compactLayout: { path: 'compact-layout.min.js', + reloadable: true, style: true, displayNames: { compactLayout: '首页使用紧凑布局' @@ -1800,6 +1813,7 @@ Resource.manifest = { }, useCommentStyle: { path: 'comment.min.js', + reloadable: true, style: 'important', displayNames: { useCommentStyle: '简化评论区' @@ -1825,6 +1839,7 @@ Resource.manifest = { }, framePlayback: { path: 'frame-playback.min.js', + reloadable: true, style: 'instant', html: true, displayNames: { @@ -1889,6 +1904,7 @@ Resource.manifest = { }, customNavbar: { path: 'custom-navbar.min.js', + reloadable: true, style: 'instant', html: true, displayNames: { @@ -1917,24 +1933,28 @@ Resource.manifest = { }, playerShadow: { path: 'player-shadow.min.js', + reloadable: true, displayNames: { playerShadow: '播放器投影' } }, narrowDanmaku: { path: 'narrow-danmaku.min.js', + reloadable: true, displayNames: { narrowDanmaku: '强制保留弹幕栏' } }, hideOldEntry: { path: 'hide-old-entry.min.js', + reloadable: true, displayNames: { hideOldEntry: '隐藏返回旧版' } }, videoScreenshot: { path: 'screenshot.min.js', + reloadable: true, style: true, displayNames: { videoScreenshot: '启用视频截图' @@ -1945,6 +1965,7 @@ Resource.manifest = { }, hideBangumiReviews: { path: 'hide-bangumi-reviews.min.js', + reloadable: true, displayNames: { hideBangumiReviews: '隐藏番剧点评' } @@ -1964,6 +1985,7 @@ Resource.manifest = { }, hideCategory: { path: 'hide-category.min.js', + reloadable: true, style: 'instant', displayNames: { hideCategory: '隐藏分区栏', @@ -2027,6 +2049,7 @@ Resource.manifest = { }, fullActivityContent: { path: 'full-activity-content.min.js', + reloadable: true, displayNames: { fullActivityContent: '展开动态内容', }, @@ -2039,6 +2062,7 @@ Resource.manifest = { }, selectableColumnText: { path: 'selectable-column-text.min.js', + reloadable: true, displayNames: { selectableColumnText: '专栏文字选择', }, diff --git a/bilibili-evolved.user.js b/bilibili-evolved.user.js index 08446c29f..fe9bec0c0 100644 --- a/bilibili-evolved.user.js +++ b/bilibili-evolved.user.js @@ -572,31 +572,35 @@ function loadResources () { Resource.root = 'https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/' Resource.all = {} Resource.displayNames = {} - Resource.reloadables = [ - 'useDarkStyle', - 'hideBanner', - 'customNavbar', - 'playerShadow', - 'narrowDanmaku', - 'compactLayout', - 'useCommentStyle', - 'removeVideoTopMask', - 'hideOldEntry', - 'hideBangumiReviews', - 'videoScreenshot', - 'blurVideoControl', - 'customControlBackground', - 'harunaScale', - 'removeLiveWatermark', - 'framePlayback', - 'hideCategory', - 'fullTweetsTitle', - 'fullActivityContent', - ] + // Resource.reloadables = [ + // 'useDarkStyle', + // 'hideBanner', + // 'customNavbar', + // 'playerShadow', + // 'narrowDanmaku', + // 'compactLayout', + // 'useCommentStyle', + // 'removeVideoTopMask', + // 'hideOldEntry', + // 'hideBangumiReviews', + // 'videoScreenshot', + // 'blurVideoControl', + // 'customControlBackground', + // 'harunaScale', + // 'removeLiveWatermark', + // 'framePlayback', + // 'hideCategory', + // 'fullTweetsTitle', + // 'fullActivityContent', + // ] + Resource.reloadables = [] for (const [key, data] of Object.entries(Resource.manifest)) { const resource = new Resource(data.path, { styles: data.styles, alwaysPreview: data.alwaysPreview }) resource.key = key resource.dropdown = data.dropdown + if (data.reloadable) { + Resource.reloadables.push(key) + } if (data.displayNames) { resource.displayName = data.displayNames[key] Object.assign(Resource.displayNames, data.displayNames) @@ -1452,6 +1456,7 @@ Resource.manifest = { }, useDarkStyle: { path: 'dark-styles.min.js', + reloadable: true, alwaysPreview: true, styles: [ 'darkStyle', @@ -1499,6 +1504,7 @@ Resource.manifest = { }, hideBanner: { path: 'hide-banner.min.js', + reloadable: true, style: 'instant', displayNames: { hideBanner: '隐藏顶部横幅' @@ -1549,18 +1555,21 @@ Resource.manifest = { }, harunaScale: { path: 'haruna-scale.min.js', + reloadable: true, displayNames: { harunaScale: '缩放直播看板娘' } }, removeLiveWatermark: { path: 'remove-watermark.min.js', + reloadable: true, displayNames: { removeLiveWatermark: '删除直播水印' } }, fullTweetsTitle: { path: 'full-tweets-title.min.js', + reloadable: true, style: 'instant', displayNames: { fullTweetsTitle: '展开动态标题' @@ -1603,12 +1612,14 @@ Resource.manifest = { }, removeVideoTopMask: { path: 'remove-top-mask.min.js', + reloadable: true, displayNames: { removeVideoTopMask: '删除视频标题层' } }, blurVideoControl: { path: 'blur-video-control.min.js', + reloadable: true, style: 'instant', displayNames: { blurVideoControl: '模糊视频控制栏背景' @@ -1670,6 +1681,7 @@ Resource.manifest = { }, customControlBackground: { path: 'custom-control-background.min.js', + reloadable: true, style: { key: 'customControlBackgroundStyle', condition: () => settings.customControlBackgroundOpacity > 0 @@ -1767,6 +1779,7 @@ Resource.manifest = { }, compactLayout: { path: 'compact-layout.min.js', + reloadable: true, style: true, displayNames: { compactLayout: '首页使用紧凑布局' @@ -1800,6 +1813,7 @@ Resource.manifest = { }, useCommentStyle: { path: 'comment.min.js', + reloadable: true, style: 'important', displayNames: { useCommentStyle: '简化评论区' @@ -1825,6 +1839,7 @@ Resource.manifest = { }, framePlayback: { path: 'frame-playback.min.js', + reloadable: true, style: 'instant', html: true, displayNames: { @@ -1889,6 +1904,7 @@ Resource.manifest = { }, customNavbar: { path: 'custom-navbar.min.js', + reloadable: true, style: 'instant', html: true, displayNames: { @@ -1917,24 +1933,28 @@ Resource.manifest = { }, playerShadow: { path: 'player-shadow.min.js', + reloadable: true, displayNames: { playerShadow: '播放器投影' } }, narrowDanmaku: { path: 'narrow-danmaku.min.js', + reloadable: true, displayNames: { narrowDanmaku: '强制保留弹幕栏' } }, hideOldEntry: { path: 'hide-old-entry.min.js', + reloadable: true, displayNames: { hideOldEntry: '隐藏返回旧版' } }, videoScreenshot: { path: 'screenshot.min.js', + reloadable: true, style: true, displayNames: { videoScreenshot: '启用视频截图' @@ -1945,6 +1965,7 @@ Resource.manifest = { }, hideBangumiReviews: { path: 'hide-bangumi-reviews.min.js', + reloadable: true, displayNames: { hideBangumiReviews: '隐藏番剧点评' } @@ -1964,6 +1985,7 @@ Resource.manifest = { }, hideCategory: { path: 'hide-category.min.js', + reloadable: true, style: 'instant', displayNames: { hideCategory: '隐藏分区栏', @@ -2027,6 +2049,7 @@ Resource.manifest = { }, fullActivityContent: { path: 'full-activity-content.min.js', + reloadable: true, displayNames: { fullActivityContent: '展开动态内容', }, @@ -2039,6 +2062,7 @@ Resource.manifest = { }, selectableColumnText: { path: 'selectable-column-text.min.js', + reloadable: true, displayNames: { selectableColumnText: '专栏文字选择', }, diff --git a/src/client/resource-loader.js b/src/client/resource-loader.js index 59ed88577..dfd476dea 100644 --- a/src/client/resource-loader.js +++ b/src/client/resource-loader.js @@ -2,31 +2,35 @@ export function loadResources () { Resource.root = 'https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/' Resource.all = {} Resource.displayNames = {} - Resource.reloadables = [ - 'useDarkStyle', - 'hideBanner', - 'customNavbar', - 'playerShadow', - 'narrowDanmaku', - 'compactLayout', - 'useCommentStyle', - 'removeVideoTopMask', - 'hideOldEntry', - 'hideBangumiReviews', - 'videoScreenshot', - 'blurVideoControl', - 'customControlBackground', - 'harunaScale', - 'removeLiveWatermark', - 'framePlayback', - 'hideCategory', - 'fullTweetsTitle', - 'fullActivityContent', - ] + // Resource.reloadables = [ + // 'useDarkStyle', + // 'hideBanner', + // 'customNavbar', + // 'playerShadow', + // 'narrowDanmaku', + // 'compactLayout', + // 'useCommentStyle', + // 'removeVideoTopMask', + // 'hideOldEntry', + // 'hideBangumiReviews', + // 'videoScreenshot', + // 'blurVideoControl', + // 'customControlBackground', + // 'harunaScale', + // 'removeLiveWatermark', + // 'framePlayback', + // 'hideCategory', + // 'fullTweetsTitle', + // 'fullActivityContent', + // ] + Resource.reloadables = [] for (const [key, data] of Object.entries(Resource.manifest)) { const resource = new Resource(data.path, { styles: data.styles, alwaysPreview: data.alwaysPreview }) resource.key = key resource.dropdown = data.dropdown + if (data.reloadable) { + Resource.reloadables.push(key) + } if (data.displayNames) { resource.displayName = data.displayNames[key] Object.assign(Resource.displayNames, data.displayNames) diff --git a/src/client/resource-manifest.js b/src/client/resource-manifest.js index 22a1d7eb3..ec75b75f2 100644 --- a/src/client/resource-manifest.js +++ b/src/client/resource-manifest.js @@ -103,6 +103,7 @@ Resource.manifest = { }, useDarkStyle: { path: 'dark-styles.min.js', + reloadable: true, alwaysPreview: true, styles: [ 'darkStyle', @@ -150,6 +151,7 @@ Resource.manifest = { }, hideBanner: { path: 'hide-banner.min.js', + reloadable: true, style: 'instant', displayNames: { hideBanner: '隐藏顶部横幅' @@ -200,18 +202,21 @@ Resource.manifest = { }, harunaScale: { path: 'haruna-scale.min.js', + reloadable: true, displayNames: { harunaScale: '缩放直播看板娘' } }, removeLiveWatermark: { path: 'remove-watermark.min.js', + reloadable: true, displayNames: { removeLiveWatermark: '删除直播水印' } }, fullTweetsTitle: { path: 'full-tweets-title.min.js', + reloadable: true, style: 'instant', displayNames: { fullTweetsTitle: '展开动态标题' @@ -254,12 +259,14 @@ Resource.manifest = { }, removeVideoTopMask: { path: 'remove-top-mask.min.js', + reloadable: true, displayNames: { removeVideoTopMask: '删除视频标题层' } }, blurVideoControl: { path: 'blur-video-control.min.js', + reloadable: true, style: 'instant', displayNames: { blurVideoControl: '模糊视频控制栏背景' @@ -321,6 +328,7 @@ Resource.manifest = { }, customControlBackground: { path: 'custom-control-background.min.js', + reloadable: true, style: { key: 'customControlBackgroundStyle', condition: () => settings.customControlBackgroundOpacity > 0 @@ -418,6 +426,7 @@ Resource.manifest = { }, compactLayout: { path: 'compact-layout.min.js', + reloadable: true, style: true, displayNames: { compactLayout: '首页使用紧凑布局' @@ -451,6 +460,7 @@ Resource.manifest = { }, useCommentStyle: { path: 'comment.min.js', + reloadable: true, style: 'important', displayNames: { useCommentStyle: '简化评论区' @@ -476,6 +486,7 @@ Resource.manifest = { }, framePlayback: { path: 'frame-playback.min.js', + reloadable: true, style: 'instant', html: true, displayNames: { @@ -540,6 +551,7 @@ Resource.manifest = { }, customNavbar: { path: 'custom-navbar.min.js', + reloadable: true, style: 'instant', html: true, displayNames: { @@ -568,24 +580,28 @@ Resource.manifest = { }, playerShadow: { path: 'player-shadow.min.js', + reloadable: true, displayNames: { playerShadow: '播放器投影' } }, narrowDanmaku: { path: 'narrow-danmaku.min.js', + reloadable: true, displayNames: { narrowDanmaku: '强制保留弹幕栏' } }, hideOldEntry: { path: 'hide-old-entry.min.js', + reloadable: true, displayNames: { hideOldEntry: '隐藏返回旧版' } }, videoScreenshot: { path: 'screenshot.min.js', + reloadable: true, style: true, displayNames: { videoScreenshot: '启用视频截图' @@ -596,6 +612,7 @@ Resource.manifest = { }, hideBangumiReviews: { path: 'hide-bangumi-reviews.min.js', + reloadable: true, displayNames: { hideBangumiReviews: '隐藏番剧点评' } @@ -615,6 +632,7 @@ Resource.manifest = { }, hideCategory: { path: 'hide-category.min.js', + reloadable: true, style: 'instant', displayNames: { hideCategory: '隐藏分区栏', @@ -678,6 +696,7 @@ Resource.manifest = { }, fullActivityContent: { path: 'full-activity-content.min.js', + reloadable: true, displayNames: { fullActivityContent: '展开动态内容', }, @@ -690,6 +709,7 @@ Resource.manifest = { }, selectableColumnText: { path: 'selectable-column-text.min.js', + reloadable: true, displayNames: { selectableColumnText: '专栏文字选择', },