Refactor resources

This commit is contained in:
the1812 2019-03-24 13:03:39 +08:00
parent 36725a54ea
commit a556cb2045
7 changed files with 42 additions and 37 deletions

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved (Offline)
// @version 250.88
// @version 250.89
// @description Bilibili Evolved 的离线版, 所有功能都已内置于脚本中.
// @author Grant Howard, Coulomb-G
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
@ -1065,7 +1065,7 @@ class Resource
{
if (!document.querySelector(`#${id}`))
{
const element = this.getStyle(id);
const style = this.getStyle(id);
// const priorStyle = this.getPriorStyle();
// if (priorStyle === null)
// {
@ -1084,11 +1084,11 @@ class Resource
// }
if (important)
{
$("html").append(element);
document.body.insertAdjacentHTML("beforeend", style);
}
else
{
$("head").prepend(element);
document.head.insertAdjacentHTML("afterbegin", style);
}
}
}
@ -1617,7 +1617,8 @@ class StyleManager
}
removeStyle(key)
{
$(`#${this.getDefaultStyleId(key)}`).remove();
const style = document.querySelector(`#${this.getDefaultStyleId(key)}`);
style && style.remove();
}
applyImportantStyle(key, id)
{
@ -1629,11 +1630,11 @@ class StyleManager
}
applyStyleFromText(text)
{
$("head").prepend(text);
document.head.insertAdjacentHTML("afterbegin", text);
}
applyImportantStyleFromText(text)
{
$("html").append(text);
document.body.insertAdjacentHTML("beforeend", text);
}
getStyle(key, id)
{
@ -1885,7 +1886,7 @@ class ResourceManager
{
if (info.content)
{
$(".widgets-container").append($(info.content));
document.querySelector(".widgets-container").insertAdjacentHTML("beforeend", info.content);
}
if (info.success)
{

View File

@ -1,6 +1,6 @@
// ==UserScript==
// @name Bilibili Evolved (Preview Offline)
// @version 250.88
// @version 250.89
// @description Bilibili Evolved 的预览离线版, 可以抢先体验新功能, 并且所有功能都已内置于脚本中.
// @author Grant Howard, Coulomb-G
// @copyright 2019, Grant Howard (https://github.com/the1812) & Coulomb-G (https://github.com/Coulomb-G)
@ -1065,7 +1065,7 @@ class Resource
{
if (!document.querySelector(`#${id}`))
{
const element = this.getStyle(id);
const style = this.getStyle(id);
// const priorStyle = this.getPriorStyle();
// if (priorStyle === null)
// {
@ -1084,11 +1084,11 @@ class Resource
// }
if (important)
{
$("html").append(element);
document.body.insertAdjacentHTML("beforeend", style);
}
else
{
$("head").prepend(element);
document.head.insertAdjacentHTML("afterbegin", style);
}
}
}
@ -1617,7 +1617,8 @@ class StyleManager
}
removeStyle(key)
{
$(`#${this.getDefaultStyleId(key)}`).remove();
const style = document.querySelector(`#${this.getDefaultStyleId(key)}`);
style && style.remove();
}
applyImportantStyle(key, id)
{
@ -1629,11 +1630,11 @@ class StyleManager
}
applyStyleFromText(text)
{
$("head").prepend(text);
document.head.insertAdjacentHTML("afterbegin", text);
}
applyImportantStyleFromText(text)
{
$("html").append(text);
document.body.insertAdjacentHTML("beforeend", text);
}
getStyle(key, id)
{
@ -1885,7 +1886,7 @@ class ResourceManager
{
if (info.content)
{
$(".widgets-container").append($(info.content));
document.querySelector(".widgets-container").insertAdjacentHTML("beforeend", info.content);
}
if (info.success)
{

View File

@ -1013,7 +1013,7 @@ class Resource
{
if (!document.querySelector(`#${id}`))
{
const element = this.getStyle(id);
const style = this.getStyle(id);
// const priorStyle = this.getPriorStyle();
// if (priorStyle === null)
// {
@ -1032,11 +1032,11 @@ class Resource
// }
if (important)
{
$("html").append(element);
document.body.insertAdjacentHTML("beforeend", style);
}
else
{
$("head").prepend(element);
document.head.insertAdjacentHTML("afterbegin", style);
}
}
}
@ -1565,7 +1565,8 @@ class StyleManager
}
removeStyle(key)
{
$(`#${this.getDefaultStyleId(key)}`).remove();
const style = document.querySelector(`#${this.getDefaultStyleId(key)}`);
style && style.remove();
}
applyImportantStyle(key, id)
{
@ -1577,11 +1578,11 @@ class StyleManager
}
applyStyleFromText(text)
{
$("head").prepend(text);
document.head.insertAdjacentHTML("afterbegin", text);
}
applyImportantStyleFromText(text)
{
$("html").append(text);
document.body.insertAdjacentHTML("beforeend", text);
}
getStyle(key, id)
{
@ -1833,7 +1834,7 @@ class ResourceManager
{
if (info.content)
{
$(".widgets-container").append($(info.content));
document.querySelector(".widgets-container").insertAdjacentHTML("beforeend", info.content);
}
if (info.success)
{

View File

@ -1013,7 +1013,7 @@ class Resource
{
if (!document.querySelector(`#${id}`))
{
const element = this.getStyle(id);
const style = this.getStyle(id);
// const priorStyle = this.getPriorStyle();
// if (priorStyle === null)
// {
@ -1032,11 +1032,11 @@ class Resource
// }
if (important)
{
$("html").append(element);
document.body.insertAdjacentHTML("beforeend", style);
}
else
{
$("head").prepend(element);
document.head.insertAdjacentHTML("afterbegin", style);
}
}
}
@ -1565,7 +1565,8 @@ class StyleManager
}
removeStyle(key)
{
$(`#${this.getDefaultStyleId(key)}`).remove();
const style = document.querySelector(`#${this.getDefaultStyleId(key)}`);
style && style.remove();
}
applyImportantStyle(key, id)
{
@ -1577,11 +1578,11 @@ class StyleManager
}
applyStyleFromText(text)
{
$("head").prepend(text);
document.head.insertAdjacentHTML("afterbegin", text);
}
applyImportantStyleFromText(text)
{
$("html").append(text);
document.body.insertAdjacentHTML("beforeend", text);
}
getStyle(key, id)
{
@ -1833,7 +1834,7 @@ class ResourceManager
{
if (info.content)
{
$(".widgets-container").append($(info.content));
document.querySelector(".widgets-container").insertAdjacentHTML("beforeend", info.content);
}
if (info.success)
{

View File

@ -208,7 +208,7 @@ export class ResourceManager
{
if (info.content)
{
$(".widgets-container").append($(info.content));
document.querySelector(".widgets-container").insertAdjacentHTML("beforeend", info.content);
}
if (info.success)
{

View File

@ -151,7 +151,7 @@ export class Resource
{
if (!document.querySelector(`#${id}`))
{
const element = this.getStyle(id);
const style = this.getStyle(id);
// const priorStyle = this.getPriorStyle();
// if (priorStyle === null)
// {
@ -170,11 +170,11 @@ export class Resource
// }
if (important)
{
$("html").append(element);
document.body.insertAdjacentHTML("beforeend", style);
}
else
{
$("head").prepend(element);
document.head.insertAdjacentHTML("afterbegin", style);
}
}
}

View File

@ -19,7 +19,8 @@ export class StyleManager
}
removeStyle(key)
{
$(`#${this.getDefaultStyleId(key)}`).remove();
const style = document.querySelector(`#${this.getDefaultStyleId(key)}`);
style && style.remove();
}
applyImportantStyle(key, id)
{
@ -31,11 +32,11 @@ export class StyleManager
}
applyStyleFromText(text)
{
$("head").prepend(text);
document.head.insertAdjacentHTML("afterbegin", text);
}
applyImportantStyleFromText(text)
{
$("html").append(text);
document.body.insertAdjacentHTML("beforeend", text);
}
getStyle(key, id)
{