mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Refactor resources
This commit is contained in:
parent
36725a54ea
commit
a556cb2045
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user