Add always preview option

This commit is contained in:
the1812 2019-06-02 13:16:27 +08:00
parent 765d78e203
commit 4bc26a297b
9 changed files with 96 additions and 161 deletions

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved (Offline)
// @version 320.34
// @version 320.90
// @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中.
// @author Grant Howard, Coulomb-G
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
@ -534,7 +534,7 @@ function loadResources()
];
for (const [key, data] of Object.entries(Resource.manifest))
{
const resource = new Resource(data.path, data.styles);
const resource = new Resource(data.path, { styles: data.styles, alwaysPreview: data.alwaysPreview });
resource.key = key;
resource.dropdown = data.dropdown;
if (data.displayNames)
@ -545,7 +545,7 @@ function loadResources()
if (data.style)
{
const styleKey = key + "Style";
const style = Resource.all[styleKey] = new Resource(data.path.replace(".js", ".css"));
const style = Resource.all[styleKey] = new Resource(data.path.replace(".js", ".css"), { alwaysPreview: data.alwaysPreview });
style.key = styleKey;
switch (data.style)
{
@ -580,7 +580,7 @@ function loadResources()
if (data.html === true)
{
const htmlKey = key + "Html";
const html = Resource.all[htmlKey] = new Resource(data.path.replace(".js", ".html"));
const html = Resource.all[htmlKey] = new Resource(data.path.replace(".js", ".html"), { alwaysPreview: data.alwaysPreview });
html.key = htmlKey;
resource.dependencies.push(html);
}
@ -1213,17 +1213,26 @@ class Resource
{
return this.text !== null;
}
constructor(url, styles = [])
constructor(url, { styles = [], alwaysPreview: false } = {})
{
this.url = Resource.root + "min/" + url;
this.rawUrl = Resource.root + "min/" + url;
this.dependencies = [];
// this.priority = priority;
this.styles = styles;
this.text = null;
this.key = null;
this.alwaysPreview = alwaysPreview;
this.type = ResourceType.fromUrl(url);
this.displayName = "";
}
get url()
{
if (this.alwaysPreview)
{
return this.rawUrl.replace("/master/", "/preview/");
}
return this.rawUrl;
}
flatMapPolyfill()
{
if (Array.prototype.flatMap === undefined)
@ -1364,12 +1373,15 @@ Resource.manifest = {
},
darkStyle: {
path: "dark.min.css",
alwaysPreview: true,
},
darkStyleImportant: {
path: "dark-important.min.css",
alwaysPreview: true,
},
darkStyleNavBar: {
path: "dark-navbar.min.css",
alwaysPreview: true,
},
touchPlayerStyle: {
path: "touch-player.min.css",
@ -1446,6 +1458,7 @@ Resource.manifest = {
},
useDarkStyle: {
path: "dark-styles.min.js",
alwaysPreview: true,
styles: [
"darkStyle",
"scrollbarStyle",
@ -1491,22 +1504,6 @@ Resource.manifest = {
blurBackgroundOpacity: "顶栏(对横幅)透明度",
},
},
// overrideNavBar: {
// path: "override-navbar.min.js",
// styles: [
// "tweetsStyle",
// "navbarOverrideStyle",
// {
// key: "noBannerStyle",
// condition: () => !settings.showBanner
// },
// ],
// displayNames: {
// overrideNavBar: "搜索栏置顶",
// showBanner: "显示顶部横幅",
// preserveRank: "显示排行榜图标",
// },
// },
hideBanner: {
path: "hide-banner.min.js",
style: true,
@ -1800,20 +1797,10 @@ Resource.manifest = {
useCommentStyle: {
path: "comment.min.js",
style: "important",
// styles: [
// {
// key: "commentDarkStyle",
// important: true,
// condition: () => settings.useDarkStyle,
// },
// ],
displayNames: {
useCommentStyle: "简化评论区",
},
},
// commentDarkStyle: {
// path: "comment-dark.min.css"
// },
title: {
path: "title.min.js",
displayNames: {

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved (Preview Offline)
// @version 320.34
// @version 320.90
// @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中.
// @author Grant Howard, Coulomb-G
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
@ -534,7 +534,7 @@ function loadResources()
];
for (const [key, data] of Object.entries(Resource.manifest))
{
const resource = new Resource(data.path, data.styles);
const resource = new Resource(data.path, { styles: data.styles, alwaysPreview: data.alwaysPreview });
resource.key = key;
resource.dropdown = data.dropdown;
if (data.displayNames)
@ -545,7 +545,7 @@ function loadResources()
if (data.style)
{
const styleKey = key + "Style";
const style = Resource.all[styleKey] = new Resource(data.path.replace(".js", ".css"));
const style = Resource.all[styleKey] = new Resource(data.path.replace(".js", ".css"), { alwaysPreview: data.alwaysPreview });
style.key = styleKey;
switch (data.style)
{
@ -580,7 +580,7 @@ function loadResources()
if (data.html === true)
{
const htmlKey = key + "Html";
const html = Resource.all[htmlKey] = new Resource(data.path.replace(".js", ".html"));
const html = Resource.all[htmlKey] = new Resource(data.path.replace(".js", ".html"), { alwaysPreview: data.alwaysPreview });
html.key = htmlKey;
resource.dependencies.push(html);
}
@ -1213,17 +1213,26 @@ class Resource
{
return this.text !== null;
}
constructor(url, styles = [])
constructor(url, { styles = [], alwaysPreview: false } = {})
{
this.url = Resource.root + "min/" + url;
this.rawUrl = Resource.root + "min/" + url;
this.dependencies = [];
// this.priority = priority;
this.styles = styles;
this.text = null;
this.key = null;
this.alwaysPreview = alwaysPreview;
this.type = ResourceType.fromUrl(url);
this.displayName = "";
}
get url()
{
if (this.alwaysPreview)
{
return this.rawUrl.replace("/master/", "/preview/");
}
return this.rawUrl;
}
flatMapPolyfill()
{
if (Array.prototype.flatMap === undefined)
@ -1364,12 +1373,15 @@ Resource.manifest = {
},
darkStyle: {
path: "dark.min.css",
alwaysPreview: true,
},
darkStyleImportant: {
path: "dark-important.min.css",
alwaysPreview: true,
},
darkStyleNavBar: {
path: "dark-navbar.min.css",
alwaysPreview: true,
},
touchPlayerStyle: {
path: "touch-player.min.css",
@ -1446,6 +1458,7 @@ Resource.manifest = {
},
useDarkStyle: {
path: "dark-styles.min.js",
alwaysPreview: true,
styles: [
"darkStyle",
"scrollbarStyle",
@ -1491,22 +1504,6 @@ Resource.manifest = {
blurBackgroundOpacity: "顶栏(对横幅)透明度",
},
},
// overrideNavBar: {
// path: "override-navbar.min.js",
// styles: [
// "tweetsStyle",
// "navbarOverrideStyle",
// {
// key: "noBannerStyle",
// condition: () => !settings.showBanner
// },
// ],
// displayNames: {
// overrideNavBar: "搜索栏置顶",
// showBanner: "显示顶部横幅",
// preserveRank: "显示排行榜图标",
// },
// },
hideBanner: {
path: "hide-banner.min.js",
style: true,
@ -1800,20 +1797,10 @@ Resource.manifest = {
useCommentStyle: {
path: "comment.min.js",
style: "important",
// styles: [
// {
// key: "commentDarkStyle",
// important: true,
// condition: () => settings.useDarkStyle,
// },
// ],
displayNames: {
useCommentStyle: "简化评论区",
},
},
// commentDarkStyle: {
// path: "comment-dark.min.css"
// },
title: {
path: "title.min.js",
displayNames: {

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved (Preview)
// @version 1.8.4
// @version 1.8.5
// @description Bilibili Evolved 的预览版, 可以抢先体验新功能.
// @author Grant Howard, Coulomb-G
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
@ -533,7 +533,7 @@ function loadResources()
];
for (const [key, data] of Object.entries(Resource.manifest))
{
const resource = new Resource(data.path, data.styles);
const resource = new Resource(data.path, { styles: data.styles, alwaysPreview: data.alwaysPreview });
resource.key = key;
resource.dropdown = data.dropdown;
if (data.displayNames)
@ -544,7 +544,7 @@ function loadResources()
if (data.style)
{
const styleKey = key + "Style";
const style = Resource.all[styleKey] = new Resource(data.path.replace(".js", ".css"));
const style = Resource.all[styleKey] = new Resource(data.path.replace(".js", ".css"), { alwaysPreview: data.alwaysPreview });
style.key = styleKey;
switch (data.style)
{
@ -579,7 +579,7 @@ function loadResources()
if (data.html === true)
{
const htmlKey = key + "Html";
const html = Resource.all[htmlKey] = new Resource(data.path.replace(".js", ".html"));
const html = Resource.all[htmlKey] = new Resource(data.path.replace(".js", ".html"), { alwaysPreview: data.alwaysPreview });
html.key = htmlKey;
resource.dependencies.push(html);
}
@ -1093,17 +1093,26 @@ class Resource
{
return this.text !== null;
}
constructor(url, styles = [])
constructor(url, { styles = [], alwaysPreview: false } = {})
{
this.url = Resource.root + "min/" + url;
this.rawUrl = Resource.root + "min/" + url;
this.dependencies = [];
// this.priority = priority;
this.styles = styles;
this.text = null;
this.key = null;
this.alwaysPreview = alwaysPreview;
this.type = ResourceType.fromUrl(url);
this.displayName = "";
}
get url()
{
if (this.alwaysPreview)
{
return this.rawUrl.replace("/master/", "/preview/");
}
return this.rawUrl;
}
flatMapPolyfill()
{
if (Array.prototype.flatMap === undefined)
@ -1286,12 +1295,15 @@ Resource.manifest = {
},
darkStyle: {
path: "dark.min.css",
alwaysPreview: true,
},
darkStyleImportant: {
path: "dark-important.min.css",
alwaysPreview: true,
},
darkStyleNavBar: {
path: "dark-navbar.min.css",
alwaysPreview: true,
},
touchPlayerStyle: {
path: "touch-player.min.css",
@ -1368,6 +1380,7 @@ Resource.manifest = {
},
useDarkStyle: {
path: "dark-styles.min.js",
alwaysPreview: true,
styles: [
"darkStyle",
"scrollbarStyle",
@ -1413,22 +1426,6 @@ Resource.manifest = {
blurBackgroundOpacity: "顶栏(对横幅)透明度",
},
},
// overrideNavBar: {
// path: "override-navbar.min.js",
// styles: [
// "tweetsStyle",
// "navbarOverrideStyle",
// {
// key: "noBannerStyle",
// condition: () => !settings.showBanner
// },
// ],
// displayNames: {
// overrideNavBar: "搜索栏置顶",
// showBanner: "显示顶部横幅",
// preserveRank: "显示排行榜图标",
// },
// },
hideBanner: {
path: "hide-banner.min.js",
style: true,
@ -1722,20 +1719,10 @@ Resource.manifest = {
useCommentStyle: {
path: "comment.min.js",
style: "important",
// styles: [
// {
// key: "commentDarkStyle",
// important: true,
// condition: () => settings.useDarkStyle,
// },
// ],
displayNames: {
useCommentStyle: "简化评论区",
},
},
// commentDarkStyle: {
// path: "comment-dark.min.css"
// },
title: {
path: "title.min.js",
displayNames: {

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved
// @version 1.8.4
// @version 1.8.5
// @description 增强哔哩哔哩Web端体验: 下载视频, 音乐, 封面, 弹幕; 自定义播放器的画质, 模式, 布局; 自定义顶栏, 删除广告, 使用夜间模式; 以及增加对触屏设备的支持等.
// @author Grant Howard, Coulomb-G
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
@ -533,7 +533,7 @@ function loadResources()
];
for (const [key, data] of Object.entries(Resource.manifest))
{
const resource = new Resource(data.path, data.styles);
const resource = new Resource(data.path, { styles: data.styles, alwaysPreview: data.alwaysPreview });
resource.key = key;
resource.dropdown = data.dropdown;
if (data.displayNames)
@ -544,7 +544,7 @@ function loadResources()
if (data.style)
{
const styleKey = key + "Style";
const style = Resource.all[styleKey] = new Resource(data.path.replace(".js", ".css"));
const style = Resource.all[styleKey] = new Resource(data.path.replace(".js", ".css"), { alwaysPreview: data.alwaysPreview });
style.key = styleKey;
switch (data.style)
{
@ -579,7 +579,7 @@ function loadResources()
if (data.html === true)
{
const htmlKey = key + "Html";
const html = Resource.all[htmlKey] = new Resource(data.path.replace(".js", ".html"));
const html = Resource.all[htmlKey] = new Resource(data.path.replace(".js", ".html"), { alwaysPreview: data.alwaysPreview });
html.key = htmlKey;
resource.dependencies.push(html);
}
@ -1093,17 +1093,26 @@ class Resource
{
return this.text !== null;
}
constructor(url, styles = [])
constructor(url, { styles = [], alwaysPreview: false } = {})
{
this.url = Resource.root + "min/" + url;
this.rawUrl = Resource.root + "min/" + url;
this.dependencies = [];
// this.priority = priority;
this.styles = styles;
this.text = null;
this.key = null;
this.alwaysPreview = alwaysPreview;
this.type = ResourceType.fromUrl(url);
this.displayName = "";
}
get url()
{
if (this.alwaysPreview)
{
return this.rawUrl.replace("/master/", "/preview/");
}
return this.rawUrl;
}
flatMapPolyfill()
{
if (Array.prototype.flatMap === undefined)
@ -1286,12 +1295,15 @@ Resource.manifest = {
},
darkStyle: {
path: "dark.min.css",
alwaysPreview: true,
},
darkStyleImportant: {
path: "dark-important.min.css",
alwaysPreview: true,
},
darkStyleNavBar: {
path: "dark-navbar.min.css",
alwaysPreview: true,
},
touchPlayerStyle: {
path: "touch-player.min.css",
@ -1368,6 +1380,7 @@ Resource.manifest = {
},
useDarkStyle: {
path: "dark-styles.min.js",
alwaysPreview: true,
styles: [
"darkStyle",
"scrollbarStyle",
@ -1413,22 +1426,6 @@ Resource.manifest = {
blurBackgroundOpacity: "顶栏(对横幅)透明度",
},
},
// overrideNavBar: {
// path: "override-navbar.min.js",
// styles: [
// "tweetsStyle",
// "navbarOverrideStyle",
// {
// key: "noBannerStyle",
// condition: () => !settings.showBanner
// },
// ],
// displayNames: {
// overrideNavBar: "搜索栏置顶",
// showBanner: "显示顶部横幅",
// preserveRank: "显示排行榜图标",
// },
// },
hideBanner: {
path: "hide-banner.min.js",
style: true,
@ -1722,20 +1719,10 @@ Resource.manifest = {
useCommentStyle: {
path: "comment.min.js",
style: "important",
// styles: [
// {
// key: "commentDarkStyle",
// important: true,
// condition: () => settings.useDarkStyle,
// },
// ],
displayNames: {
useCommentStyle: "简化评论区",
},
},
// commentDarkStyle: {
// path: "comment-dark.min.css"
// },
title: {
path: "title.min.js",
displayNames: {

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved (Preview)
// @version 1.8.4
// @version 1.8.5
// @description Bilibili Evolved 的预览版, 可以抢先体验新功能.
// @author Grant Howard, Coulomb-G
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)

View File

@ -23,7 +23,7 @@ export function loadResources()
];
for (const [key, data] of Object.entries(Resource.manifest))
{
const resource = new Resource(data.path, data.styles);
const resource = new Resource(data.path, { styles: data.styles, alwaysPreview: data.alwaysPreview });
resource.key = key;
resource.dropdown = data.dropdown;
if (data.displayNames)
@ -34,7 +34,7 @@ export function loadResources()
if (data.style)
{
const styleKey = key + "Style";
const style = Resource.all[styleKey] = new Resource(data.path.replace(".js", ".css"));
const style = Resource.all[styleKey] = new Resource(data.path.replace(".js", ".css"), { alwaysPreview: data.alwaysPreview });
style.key = styleKey;
switch (data.style)
{
@ -69,7 +69,7 @@ export function loadResources()
if (data.html === true)
{
const htmlKey = key + "Html";
const html = Resource.all[htmlKey] = new Resource(data.path.replace(".js", ".html"));
const html = Resource.all[htmlKey] = new Resource(data.path.replace(".js", ".html"), { alwaysPreview: data.alwaysPreview });
html.key = htmlKey;
resource.dependencies.push(html);
}

View File

@ -10,12 +10,15 @@ Resource.manifest = {
},
darkStyle: {
path: "dark.min.css",
alwaysPreview: true,
},
darkStyleImportant: {
path: "dark-important.min.css",
alwaysPreview: true,
},
darkStyleNavBar: {
path: "dark-navbar.min.css",
alwaysPreview: true,
},
touchPlayerStyle: {
path: "touch-player.min.css",
@ -92,6 +95,7 @@ Resource.manifest = {
},
useDarkStyle: {
path: "dark-styles.min.js",
alwaysPreview: true,
styles: [
"darkStyle",
"scrollbarStyle",
@ -137,22 +141,6 @@ Resource.manifest = {
blurBackgroundOpacity: "顶栏(对横幅)透明度",
},
},
// overrideNavBar: {
// path: "override-navbar.min.js",
// styles: [
// "tweetsStyle",
// "navbarOverrideStyle",
// {
// key: "noBannerStyle",
// condition: () => !settings.showBanner
// },
// ],
// displayNames: {
// overrideNavBar: "搜索栏置顶",
// showBanner: "显示顶部横幅",
// preserveRank: "显示排行榜图标",
// },
// },
hideBanner: {
path: "hide-banner.min.js",
style: true,
@ -446,20 +434,10 @@ Resource.manifest = {
useCommentStyle: {
path: "comment.min.js",
style: "important",
// styles: [
// {
// key: "commentDarkStyle",
// important: true,
// condition: () => settings.useDarkStyle,
// },
// ],
displayNames: {
useCommentStyle: "简化评论区",
},
},
// commentDarkStyle: {
// path: "comment-dark.min.css"
// },
title: {
path: "title.min.js",
displayNames: {

View File

@ -4,17 +4,26 @@ export class Resource
{
return this.text !== null;
}
constructor(url, styles = [])
constructor(url, { styles = [], alwaysPreview: false } = {})
{
this.url = Resource.root + "min/" + url;
this.rawUrl = Resource.root + "min/" + url;
this.dependencies = [];
// this.priority = priority;
this.styles = styles;
this.text = null;
this.key = null;
this.alwaysPreview = alwaysPreview;
this.type = ResourceType.fromUrl(url);
this.displayName = "";
}
get url()
{
if (this.alwaysPreview)
{
return this.rawUrl.replace("/master/", "/preview/");
}
return this.rawUrl;
}
flatMapPolyfill()
{
if (Array.prototype.flatMap === undefined)

View File

@ -1 +1 @@
1.8.4
1.8.5