Use tampermonkey API to get update url and version

This commit is contained in:
the1812 2018-10-28 14:21:27 +08:00
parent 58a97dd7b7
commit fa612fed71
13 changed files with 159 additions and 51 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved (Preview)
// @version 1.5.21
// @version 1.5.22
// @description 增强哔哩哔哩Web端体验(预览版分支): 修复界面瑕疵, 删除广告, 使用夜间模式浏览, 下载视频或视频封面, 以及增加对触屏设备的支持等.
// @author Grant Howard, Coulomb-G
// @copyright 2018, Grant Howrad (https://github.com/the1812)
@ -17,6 +17,7 @@
// @grant GM_setValue
// @grant GM_addValueChangeListener
// @grant GM_setClipboard
// @grant GM_info
// @require https://code.jquery.com/jquery-3.2.1.min.js
// @require https://cdn.bootcss.com/jszip/3.1.5/jszip.min.js
// @icon https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/images/logo.png
@ -61,8 +62,8 @@
clearCache: true,
fixFullscreen: false,
downloadVideo: true,
latestVersionLink: "https://github.com/the1812/Bilibili-Evolved/raw/preview/bilibili-evolved.preview.user.js",
currentVersion: "1.5.21"
latestVersionLink: GM_info.script.updateURL,
currentVersion: GM_info.script.version
};
function loadSettings()
{
@ -91,7 +92,7 @@
}
function loadResources()
{
const resouceData = {
const resouceManifest = {
style: {
path: "min/style.min.scss",
order: 1
@ -356,12 +357,25 @@
},
videoInfo: {
path: "min/video-info.min.js"
},
aboutDom: {
path: "min/about.min.html"
},
aboutStyle: {
path: "min/about.min.scss"
},
about: {
path: "min/about.min.js",
dependencies: [
"aboutDom",
"aboutStyle"
]
}
};
Resource.root = "https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/";
Resource.all = {};
Resource.displayNames = {};
for (const [key, data] of Object.entries(resouceData))
for (const [key, data] of Object.entries(resouceManifest))
{
const resource = new Resource(data.path, data.order);
resource.key = key;
@ -372,7 +386,7 @@
}
Resource.all[key] = resource;
}
for (const [key, data] of Object.entries(resouceData))
for (const [key, data] of Object.entries(resouceManifest))
{
if (data.dependencies)
{

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved
// @version 1.5.21
// @version 1.5.22
// @description 增强哔哩哔哩Web端体验: 修复界面瑕疵, 删除广告, 使用夜间模式浏览, 下载视频或视频封面, 以及增加对触屏设备的支持等.
// @author Grant Howard, Coulomb-G
// @copyright 2018, Grant Howrad (https://github.com/the1812)
@ -17,6 +17,7 @@
// @grant GM_setValue
// @grant GM_addValueChangeListener
// @grant GM_setClipboard
// @grant GM_info
// @require https://code.jquery.com/jquery-3.2.1.min.js
// @require https://cdn.bootcss.com/jszip/3.1.5/jszip.min.js
// @icon https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/images/logo.png
@ -61,8 +62,8 @@
clearCache: true,
fixFullscreen: false,
downloadVideo: true,
latestVersionLink: "https://github.com/the1812/Bilibili-Evolved/raw/master/bilibili-evolved.user.js",
currentVersion: "1.5.21"
latestVersionLink: GM_info.script.updateURL,
currentVersion: GM_info.script.version
};
function loadSettings()
{
@ -91,7 +92,7 @@
}
function loadResources()
{
const resouceData = {
const resouceManifest = {
style: {
path: "min/style.min.scss",
order: 1
@ -356,12 +357,25 @@
},
videoInfo: {
path: "min/video-info.min.js"
},
aboutDom: {
path: "min/about.min.html"
},
aboutStyle: {
path: "min/about.min.scss"
},
about: {
path: "min/about.min.js",
dependencies: [
"aboutDom",
"aboutStyle"
]
}
};
Resource.root = "https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/";
Resource.all = {};
Resource.displayNames = {};
for (const [key, data] of Object.entries(resouceData))
for (const [key, data] of Object.entries(resouceManifest))
{
const resource = new Resource(data.path, data.order);
resource.key = key;
@ -372,7 +386,7 @@
}
Resource.all[key] = resource;
}
for (const [key, data] of Object.entries(resouceData))
for (const [key, data] of Object.entries(resouceManifest))
{
if (data.dependencies)
{

View File

@ -0,0 +1 @@
<div class="bilibili-evolved-about"></div>

1
min/about.min.js vendored
View File

@ -0,0 +1 @@
(()=>{return(t,n)=>{$("body").append(n.data.aboutDom.text);function i(){}return{settingsWidget:{after:()=>$(".gui-settings-content"),content:`\n <div class="about gui-settings-footer">\n <span id="about-version">Bilibili Evolved ${t.currentVersion}</span>\n <span id="about-link">About</span>\n </div>`,success:i}}}})();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
<div class="bilibili-evolved-about">
</div>

View File

@ -0,0 +1,22 @@
(() =>
{
return (settings, resources) =>
{
$("body").append(resources.data.aboutDom.text);
function init()
{
}
return {
settingsWidget: {
after: () => $(".gui-settings-content"),
content: `
<div class="about gui-settings-footer">
<span id="about-version">Bilibili Evolved ${settings.currentVersion}</span>
<span id="about-link">About</span>
</div>`,
success: init
}
};
};
})();

View File

@ -257,23 +257,8 @@
});
}
}
addSettingsIcon($("body"));
const settingsBox = resources.data.guiSettingsDom.text;
if (settingsBox)
function applyBlurEffect()
{
$("body").append(settingsBox);
setupEvents();
fillSvgData();
if (typeof offlineData !== "undefined")
{
$("li:has(input[key=useCache])").addClass("disabled");
$("input[key=useCache]").prop("disabled", true);
}
syncGui();
listenDependencies();
addPredefinedColors();
listenSettingsChange();
if (settings.blurSettingsPanel)
{
$(".gui-settings-box").addClass("blur");
@ -283,6 +268,29 @@
$(".gui-settings-panel").addClass("animation");
}
}
function checkOfflineData()
{
if (typeof offlineData !== "undefined")
{
$("li:has(input[key=useCache])").addClass("disabled");
$("input[key=useCache]").prop("disabled", true);
}
}
addSettingsIcon($("body"));
const settingsBox = resources.data.guiSettingsDom.text;
if (settingsBox)
{
$("body").append(settingsBox);
setupEvents();
fillSvgData();
checkOfflineData();
syncGui();
listenDependencies();
addPredefinedColors();
listenSettingsChange();
applyBlurEffect();
}
new SpinQuery(
() => $("body"),

View File

@ -102,7 +102,6 @@
overflow: auto;
position: relative;
overscroll-behavior: contain;
padding-bottom: 16px;
}
.gui-settings-content-top-mask,
.gui-settings-content-bottom-mask
@ -512,3 +511,15 @@ i.settings-category-arrow::after
border-top-color: transparent;
border-radius: 2.4px;
}
.about.gui-settings-footer
{
height: 24px;
font-size: 16px;
justify-content: space-between;
padding: 6px 24px;
border-top: 1px dashed #8884;
}
.about.gui-settings-footer>span
{
opacity: 0.2;
}

View File

@ -1 +1 @@
1.5.21
1.5.22