>> 0, 8 | types.mapKey[field.keyType], field.keyType);
if (wireType === void 0)
gen("types[%i].encode(%s[ks[i]],w.uint32(18).fork()).ldelim().ldelim()", index, ref);
else
gen(".uint32(%i).%s(%s[ks[i]]).ldelim()", 16 | wireType, type, ref);
gen("}")("}");
} else if (field.repeated) {
gen("if(%s!=null&&%s.length){", ref, ref);
if (field.packed && types.packed[type] !== void 0) {
gen("w.uint32(%i).fork()", (field.id << 3 | 2) >>> 0)("for(var i=0;i<%s.length;++i)", ref)("w.%s(%s[i])", type, ref)("w.ldelim()");
} else {
gen("for(var i=0;i<%s.length;++i)", ref);
if (wireType === void 0)
genTypePartial(gen, field, index, ref + "[i]");
else
gen("w.uint32(%i).%s(%s[i])", (field.id << 3 | wireType) >>> 0, type, ref);
}
gen("}");
} else {
if (field.optional)
gen("if(%s!=null&&Object.hasOwnProperty.call(m,%j))", ref, field.name);
if (wireType === void 0)
genTypePartial(gen, field, index, ref);
else
gen("w.uint32(%i).%s(%s)", (field.id << 3 | wireType) >>> 0, type, ref);
}
}
return gen("return w");
}
}
});
// node_modules/protobufjs/src/index-light.js
var require_index_light = __commonJS({
"node_modules/protobufjs/src/index-light.js"(exports2, module2) {
"use strict";
var protobuf = module2.exports = require_index_minimal();
protobuf.build = "light";
function load2(filename, root, callback) {
if (typeof root === "function") {
callback = root;
root = new protobuf.Root();
} else if (!root)
root = new protobuf.Root();
return root.load(filename, callback);
}
protobuf.load = load2;
function loadSync(filename, root) {
if (!root)
root = new protobuf.Root();
return root.loadSync(filename);
}
protobuf.loadSync = loadSync;
protobuf.encoder = require_encoder();
protobuf.decoder = require_decoder();
protobuf.verifier = require_verifier();
protobuf.converter = require_converter();
protobuf.ReflectionObject = require_object2();
protobuf.Namespace = require_namespace();
protobuf.Root = require_root();
protobuf.Enum = require_enum();
protobuf.Type = require_type();
protobuf.Field = require_field();
protobuf.OneOf = require_oneof();
protobuf.MapField = require_mapfield();
protobuf.Service = require_service2();
protobuf.Method = require_method();
protobuf.Message = require_message();
protobuf.wrappers = require_wrappers();
protobuf.types = require_types();
protobuf.util = require_util();
protobuf.ReflectionObject._configure(protobuf.Root);
protobuf.Namespace._configure(protobuf.Type, protobuf.Service, protobuf.Enum);
protobuf.Root._configure(protobuf.Type);
protobuf.Field._configure(protobuf.Type);
}
});
// node_modules/protobufjs/light.js
var require_light = __commonJS({
"node_modules/protobufjs/light.js"(exports2, module2) {
"use strict";
module2.exports = require_index_light();
}
});
// src/utils/format/integer.ts
function integerFormat(num, byte = 2) {
return num < 10 ** byte ? (Array(byte).join("0") + num).slice(-1 * byte) : num;
}
// src/utils/format/time.ts
function timeFormat(time = new Date().getTime(), type) {
const date = new Date(time);
const arr2 = date.toLocaleString().split(" ");
const day = arr2[0].split("/");
day[1] = integerFormat(day[1], 2);
day[2] = integerFormat(day[2], 2);
return type ? day.join("-") + " " + arr2[1] : arr2[1];
}
// src/utils/debug.ts
var group = {
i: 0,
call: []
};
function debug(...data) {
group.call.push(console.log.bind(console, \`%c[\${timeFormat()}]\`, "color: blue;", ...arguments));
!group.i && setTimeout(group.call.shift());
return debug;
}
debug.assert = function(condition, ...data) {
group.call.push(console.assert.bind(console, \`[\${timeFormat()}]\`, ...arguments));
!group.i && setTimeout(group.call.shift());
return debug;
};
debug.clear = function() {
group.i = 0;
group.call = [];
setTimeout(console.clear.bind(console));
return debug;
};
debug.debug = function(...data) {
group.call.push(console.debug.bind(console, \`[\${timeFormat()}]\`, ...arguments));
!group.i && setTimeout(group.call.shift());
return debug;
};
debug.error = function(...data) {
group.call.push(console.error.bind(console, \`[\${timeFormat()}]\`, ...arguments));
!group.i && setTimeout(group.call.shift());
return debug;
};
debug.group = function(...data) {
group.i++;
group.call.push(console.group.bind(console, \`[\${timeFormat()}]\`, ...arguments));
return debug;
};
debug.groupCollapsed = function(...data) {
group.i++;
group.call.push(console.groupCollapsed.bind(console, \`[\${timeFormat()}]\`, ...arguments));
return debug;
};
debug.groupEnd = function() {
if (group.i) {
group.i--;
group.call.push(console.groupEnd.bind(console));
!group.i && (group.call.push(() => group.call = []), group.call.forEach((d) => setTimeout(d)));
}
return debug;
};
debug.info = function(...data) {
group.call.push(console.info.bind(console, \`%c[\${timeFormat()}]\`, "color: blue;", ...arguments));
!group.i && setTimeout(group.call.shift());
return debug;
};
debug.log = function(...data) {
group.call.push(console.log.bind(console, \`%c[\${timeFormat()}]\`, "color: blue;", ...arguments));
!group.i && setTimeout(group.call.shift());
return debug;
};
debug.table = function(tabularData, properties) {
group.call.push(console.table.bind(console, ...arguments));
!group.i && setTimeout(group.call.shift());
return debug;
};
debug.time = function(label) {
console.time(label);
return debug;
};
debug.timeEnd = function(label) {
console.timeEnd(label);
return debug;
};
debug.timeLog = function(label, ...data) {
console.timeLog(label, \`[\${timeFormat()}]\`, ...data);
return debug;
};
debug.trace = function(...data) {
group.call.push(console.trace.bind(console, ...arguments));
!group.i && setTimeout(group.call.shift());
return debug;
};
debug.warn = function(...data) {
group.call.push(console.warn.bind(console, \`[\${timeFormat()}]\`, ...arguments));
!group.i && setTimeout(group.call.shift());
return debug;
};
// src/utils/file.ts
function readAs(file, type = "string", encoding = "utf-8") {
return new Promise((resolve, reject) => {
const reader = new FileReader();
switch (type) {
case "ArrayBuffer":
reader.readAsArrayBuffer(file);
break;
case "DataURL":
reader.readAsDataURL(file);
break;
case "string":
reader.readAsText(file, encoding);
break;
}
reader.onload = () => resolve(reader.result);
reader.onerror = (e) => reject(e);
});
}
async function saveAs(content, fileName, contentType = "text/plain") {
const a = document.createElement("a");
const file = new Blob([content], { type: contentType });
a.href = URL.createObjectURL(file);
a.download = fileName;
a.addEventListener("load", () => URL.revokeObjectURL(a.href));
a.click();
}
function fileRead(accept, multiple) {
return new Promise((resolve, reject) => {
const input = document.createElement("input");
let selected = false;
input.type = "file";
accept && (input.accept = accept);
multiple && (input.multiple = multiple);
input.style.opacity = "0";
input.addEventListener("change", () => {
selected = true;
resolve(input.files);
});
document.body.appendChild(input);
input.click();
window.addEventListener("focus", () => {
setTimeout(() => {
selected || reject("取消选择~");
}, 100);
}, { once: true });
});
}
// src/utils/typeof.ts
var isArray = Array.isArray;
var isObject = (val) => val !== null && typeof val === "object";
var isNumber = (val) => !isNaN(parseFloat(val)) && isFinite(val);
// src/utils/hook/method.ts
function methodHook(target, propertyKey, callback, modifyArguments) {
try {
let modify2 = function() {
loaded = true;
if (values[0]) {
Reflect.defineProperty(target, propertyKey, { configurable: true, value: values[0] });
iArguments.forEach((d) => values[0](...d));
} else {
debug.error("拦截方法出错!", "目标方法", propertyKey, "所属对象", target);
}
};
var modify = modify2;
const values = [];
const iArguments = [];
let loading2 = false;
let loaded = false;
Reflect.defineProperty(target, propertyKey, {
configurable: true,
set: (v) => {
if (loading2 && !loaded) {
values.unshift(v);
}
return true;
},
get: () => {
if (!loading2) {
loading2 = true;
setTimeout(() => {
const res = callback();
if (res && res.finally) {
res.finally(() => modify2());
} else {
modify2();
}
});
}
return function() {
modifyArguments?.(arguments);
iArguments.push(arguments);
};
}
});
} catch (e) {
debug.error(e);
}
}
function propertyHook(target, propertyKey, propertyValue, configurable = true) {
try {
Reflect.defineProperty(target, propertyKey, {
configurable,
set: (v) => true,
get: () => {
Reflect.defineProperty(target, propertyKey, { configurable: true, value: propertyValue });
return propertyValue;
}
});
} catch (e) {
debug.error(e);
}
}
propertyHook.modify = (target, propertyKey, callback, once = false) => {
try {
let value = target[propertyKey];
value && (value = callback(value));
Reflect.defineProperty(target, propertyKey, {
configurable: true,
set: (v) => {
value = callback(v);
return true;
},
get: () => {
if (once) {
Reflect.deleteProperty(target, propertyKey);
Reflect.set(target, propertyKey, value);
}
return value;
}
});
} catch (e) {
debug.error(e);
}
};
function ProxyHandler(target, parrent, key) {
return new Proxy(target, {
deleteProperty(target2, p) {
const res = Reflect.deleteProperty(target2, p);
parrent[key] = target2;
return res;
},
set(target2, p, newValue, receiver) {
const res = Reflect.set(target2, p, newValue, receiver);
parrent[key] = target2;
return res;
},
get(target2, p, receiver) {
const res = Reflect.get(target2, p, receiver);
if (isArray(res) || isObject(res)) {
return ProxyHandler(res, receiver, p);
}
return res;
}
});
}
function propertryChangeHook(target, callback) {
return new Proxy(target, {
deleteProperty(target2, p) {
const res = Reflect.deleteProperty(target2, p);
callback(p, void 0);
return res;
},
set(target2, p, newValue, receiver) {
const res = Reflect.set(target2, p, newValue, receiver);
callback(p, newValue);
return res;
},
get(target2, p, receiver) {
const res = Reflect.get(target2, p, receiver);
if (isArray(res) || isObject(res)) {
return ProxyHandler(res, receiver, p);
}
return res;
}
});
}
// src/utils/poll.ts
function poll(check, callback, delay = 100, stop = 180) {
let timer = setInterval(() => {
const d = check();
if (d) {
clearInterval(timer);
callback(d);
}
}, delay);
stop && setTimeout(() => clearInterval(timer), stop * 1e3);
}
// src/utils/element.ts
function addElement(tag, attribute, parrent, innerHTML, top, replaced) {
let element = document.createElement(tag);
attribute && Object.entries(attribute).forEach((d) => element.setAttribute(d[0], d[1]));
parrent = parrent || document.body;
innerHTML && (element.innerHTML = innerHTML);
replaced ? replaced.replaceWith(element) : top ? parrent.insertBefore(element, parrent.firstChild) : parrent.appendChild(element);
return element;
}
async function addCss(txt, id, parrent) {
if (!parrent && !document.head) {
await new Promise((r) => poll(() => document.body, r));
}
parrent = parrent || document.head;
const style = document.createElement("style");
style.setAttribute("type", "text/css");
id && !parrent.querySelector(\`#\${id}\`) && style.setAttribute("id", id);
style.appendChild(document.createTextNode(txt));
parrent.appendChild(style);
return style;
}
function loadScript(src, onload) {
return new Promise((r, j) => {
const script = document.createElement("script");
script.type = "text/javascript";
script.src = src;
script.addEventListener("load", () => {
script.remove();
onload && onload();
r(true);
});
script.addEventListener("error", () => {
script.remove();
j();
});
(document.body || document.head || document.documentElement || document).appendChild(script);
});
}
function getTotalTop(node) {
var sum = 0;
do {
sum += node.offsetTop;
node = node.offsetParent;
} while (node);
return sum;
}
// src/html/button.html
var button_default = '按钮
\\r\\n';
// src/core/ui/utils/button.ts
var PushButton = class extends HTMLElement {
_button;
constructor() {
super();
const root = this.attachShadow({ mode: "closed" });
root.innerHTML = button_default;
this._button = root.querySelector(".button");
this._button.addEventListener("click", (e) => {
e.stopPropagation();
this.dispatchEvent(new Event("change"));
});
}
set text(v) {
this._button.textContent = v;
}
};
customElements.get(\`button-\${"6ca42c3"}\`) || customElements.define(\`button-\${"6ca42c3"}\`, PushButton);
// src/html/popupbox.html
var popupbox_default = '\\r\\n';
// src/svg/fork.svg
var fork_default = '';
// src/svg/gear.svg
var gear_default = '';
// src/svg/wrench.svg
var wrench_default = '';
// src/svg/note.svg
var note_default = '';
// src/svg/dmset.svg
var dmset_default = '';
// src/svg/stethoscope.svg
var stethoscope_default = '';
// src/svg/play.svg
var play_default = '';
// src/svg/palette.svg
var palette_default = '';
// src/svg/download.svg
var download_default = '';
// src/svg/warn.svg
var warn_default = '';
// src/svg/linechart.svg
var linechart_default = '';
// src/svg/blind.svg
var blind_default = '';
// src/svg/like.svg
var like_default = '';
// src/svg/dislike.svg
var dislike_default = '';
// src/utils/svg.ts
var svg = {
fork: fork_default,
gear: gear_default,
wrench: wrench_default,
note: note_default,
dmset: dmset_default,
stethoscope: stethoscope_default,
play: play_default,
palette: palette_default,
download: download_default,
warn: warn_default,
linechart: linechart_default,
blind: blind_default,
like: like_default,
dislike: dislike_default
};
// src/core/ui/utils/popupbox.ts
var ClickOutRemove = class {
constructor(target) {
this.target = target;
target.addEventListener("click", (e) => e.stopPropagation());
}
enabled = false;
remove = () => {
this.target.remove();
};
disable = () => {
if (this.enabled) {
document.removeEventListener("click", this.remove);
this.enabled = false;
}
return this;
};
enable = () => {
this.enabled || setTimeout(() => {
document.addEventListener("click", this.remove, { once: true });
this.enabled = true;
}, 100);
return this;
};
};
var PopupBox = class extends HTMLElement {
_contain;
_fork;
clickOutRemove;
\$fork = true;
constructor() {
super();
const root = this.attachShadow({ mode: "closed" });
root.innerHTML = popupbox_default;
this._contain = root.children[0].children[0];
this._fork = root.children[0].children[1];
this._fork.innerHTML = svg.fork;
this._fork.addEventListener("click", () => this.remove());
this.clickOutRemove = new ClickOutRemove(this);
document.body.appendChild(this);
}
append(...nodes) {
this._contain.append(...nodes);
}
appendChild(node) {
this._contain.appendChild(node);
return node;
}
replaceChildren(...nodes) {
this._contain.replaceChildren(...nodes);
}
setAttribute(qualifiedName, value) {
this._contain.setAttribute(qualifiedName, value);
}
getAttribute(qualifiedName) {
return this._contain.getAttribute(qualifiedName);
}
get style() {
return this._contain.style;
}
get innerHTML() {
return this._contain.innerHTML;
}
set innerHTML(v) {
this._contain.innerHTML = v;
}
get fork() {
return this.\$fork;
}
set fork(v) {
this.\$fork = v;
this._fork.style.display = v ? "" : "none";
if (v) {
this.clickOutRemove.disable();
} else {
this.clickOutRemove.enable();
}
}
};
customElements.get(\`popupbox-\${"6ca42c3"}\`) || customElements.define(\`popupbox-\${"6ca42c3"}\`, PopupBox);
// src/core/ui/alert.ts
function alert(msg, title, buttons) {
isArray(msg) || (msg = [msg]);
msg = msg.join("");
const popup = new PopupBox();
popup.fork = false;
popup.setAttribute("style", "max-width: 400px; max-height: 300px;line-height: 16px;");
popup.innerHTML = \`
\${title || "Bilibili Old"}
\`;
if (buttons) {
addElement("hr", { style: "width: 100%;opacity: .3;" }, popup);
const div = addElement("div", { style: "display: flex;align-items: center;justify-content: space-around;" }, popup);
buttons.forEach((d) => {
const button = new PushButton();
button.text = d.text;
button.addEventListener("change", () => {
d.callback?.();
popup.remove();
});
div.appendChild(button);
});
}
}
// src/html/toast.html
var toast_default = '\\r\\n\\r\\n';
// src/utils/type.ts
function toObject(input) {
switch (input) {
case "undefined":
input = void 0;
break;
case "null":
input = null;
break;
case "NaN":
input = NaN;
break;
default:
if (!input)
break;
try {
const temp = JSON.parse(input);
if (typeof temp !== "number" || input === String(temp)) {
input = temp;
}
} catch {
try {
const temp = Number(input);
if (String(temp) !== "NaN" && !input.startsWith("0")) {
input = temp;
}
} catch {
}
try {
if (/^\\d+n\$/.test(input))
input = BigInt(input.slice(0, -1));
} catch {
}
}
break;
}
return input;
}
function toString(input, space = "\\n") {
let result;
try {
result = input.toString();
} catch {
result = String(input);
}
if (result.startsWith("[object") && result.endsWith("]")) {
try {
const str = JSON.stringify(input, void 0, space);
str === "{}" || (result = str);
} catch {
}
}
return result;
}
// src/core/toast.ts
var Toastconfig = {
position: "top-right",
rtl: false,
delay: 4,
disabled: false
};
var Toast = class extends HTMLDivElement {
closeButton = document.createElement("div");
message = document.createElement("div");
timer;
hovering = false;
timeout = false;
constructor() {
super();
this.classList.add("toast");
this.setAttribute("aria-live", "assertive");
this.setAttribute("style", "padding-top: 0px;padding-bottom: 0px;height: 0px;");
this.appendChild(this.message);
this.message.className = "toast-message";
this.closeButton.className = "toast-close-button";
this.closeButton.innerHTML = svg.fork;
this.closeButton.addEventListener("click", (e) => {
this.timeout = true;
this.delay = 1;
e.stopPropagation();
});
this.addEventListener("mouseover", () => this.hovering = true);
this.addEventListener("mouseout", () => {
this.hovering = false;
this.timeout && (this.delay = 1);
});
}
set data(v) {
isArray(v) || (v = [v]);
let html = "";
v.forEach((d, i) => {
d = toString(d);
html += i ? \`
\${d}\` : \`\`;
});
const close = this.message.contains(this.closeButton);
this.message.innerHTML = html;
close && (this.delay = 0);
this.setAttribute("style", \`height: \${this.message.scrollHeight + 30}px;\`);
}
set type(v) {
this.classList.remove("toast-success", "toast-error", "toast-info", "toast-warning");
v && this.classList.add(\`toast-\${v}\`);
}
set rtl(v) {
v ? this.classList.add("rtl") : this.classList.remove("rtl");
}
set delay(v) {
clearTimeout(this.timer);
v = Math.max(Math.trunc(v), 0);
v ? this.message.contains(this.closeButton) && this.closeButton.remove() : this.message.contains(this.closeButton) || this.message.insertBefore(this.closeButton, this.message.firstChild);
if (v === 1) {
if (!this.hovering) {
this.setAttribute("style", "padding-top: 0px;padding-bottom: 0px;height: 0px;");
setTimeout(() => this.remove(), 1e3);
}
} else if (v !== 0) {
this.timer = setTimeout(() => {
this.timeout = true;
this.delay = 1;
}, v * 1e3);
}
}
};
customElements.get(\`toast-\${"6ca42c3"}\`) || customElements.define(\`toast-\${"6ca42c3"}\`, Toast, { extends: "div" });
var ToastContainer = class extends HTMLElement {
container;
static get observedAttributes() {
return [
"position",
"rtl",
"delay",
"disabled"
];
}
constructor() {
super();
const root = this.attachShadow({ mode: "closed" });
root.innerHTML = toast_default;
this.container = root.children[0];
}
update(value) {
Object.entries(value).forEach((d) => {
this[d[0]] = d[1];
});
}
toast(delay, type = "info", ...data) {
document.body.contains(this) || document.body.appendChild(this);
const toast = new Toast();
toast.type = type;
toast.rtl = this.rtl;
this.container.insertBefore(toast, this.container.firstChild);
toast.data = data;
toast.delay = delay;
return toast;
}
success(...data) {
this.toast(this.delay, "success", ...data);
return () => {
debug(...data);
};
}
error(...data) {
this.toast(this.delay, "error", ...data);
return () => {
debug.error(...data);
};
}
info(...data) {
this.toast(this.delay, "info", ...data);
return () => {
debug.debug(...data);
};
}
warning(...data) {
this.toast(this.delay, "warning", ...data);
return () => {
debug.warn(...data);
};
}
set position(v) {
this.setAttribute("position", v);
}
get position() {
return this.getAttribute("position");
}
set rtl(v) {
this.setAttribute("rtl", v);
}
get rtl() {
return toObject(this.getAttribute("rtl"));
}
set delay(v) {
this.setAttribute("delay", v);
}
get delay() {
return toObject(this.getAttribute("delay"));
}
set disabled(v) {
this.setAttribute("disabled", v);
}
get disabled() {
return toObject(this.getAttribute("disabled"));
}
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue === newValue)
return;
switch (name) {
case "position":
newValue && (this.container.className = \`toast-\${newValue}\`);
break;
case "rtl":
this.container.querySelectorAll(".toast").forEach((d) => {
d.rtl = toObject(newValue);
});
break;
case "delay":
this.container.querySelectorAll(".toast").forEach((d) => {
d.delay = toObject(newValue);
});
break;
case "disabled":
this.container.style.display = toObject(newValue) ? "none" : "";
default:
break;
}
}
};
customElements.get(\`toast-container-\${"6ca42c3"}\`) || customElements.define(\`toast-container-\${"6ca42c3"}\`, ToastContainer);
// src/html/ui-entry.html
var ui_entry_default = '\\r\\n 设置\\r\\n
\\r\\n\\r\\n';
// src/core/ui/entry.ts
var UiEntryType = "new";
var BilioldEntry = class extends HTMLElement {
stage;
gear;
root;
static get observedAttributes() {
return [
"type"
];
}
constructor() {
super();
this.root = this.attachShadow({ mode: "closed" });
this.root.innerHTML = ui_entry_default;
this.stage = this.root.children[0];
this.gear = this.root.children[1];
this.gear.innerHTML = svg.gear;
this.stage.remove();
this.gear.remove();
this.gear.addEventListener("mouseover", () => this.gear.style.opacity = "0.8");
this.gear.addEventListener("mouseout", () => this.gear.style.opacity = "0");
}
get type() {
return this.getAttribute("type");
}
set type(v) {
this.setAttribute("type", v);
}
attributeChangedCallback(name, oldValue, newValue) {
if (oldValue === newValue)
return;
switch (name) {
case "type":
if (newValue === "old") {
this.root.contains(this.gear) && this.gear.remove();
this.root.contains(this.stage) || this.root.appendChild(this.stage);
} else {
this.root.contains(this.stage) && this.stage.remove();
if (!this.root.contains(this.gear)) {
this.root.appendChild(this.gear);
setTimeout(() => {
this.gear.style.opacity = "0";
}, 2e3);
}
}
break;
default:
break;
}
}
};
customElements.get("biliold-entry-6ca42c3") || customElements.define("bilibili-entry-6ca42c3", BilioldEntry);
// src/core/userstatus.ts
var userStatus = {
development: true,
index: true,
toast: Toastconfig,
header: true,
comment: true,
av: true,
player: true,
webRTC: false,
elecShow: true,
staff: false,
bangumi: true,
videoLimit: {
status: false,
server: "内置",
th: "api.global.bilibili.com",
tw: "",
hk: "",
cn: ""
},
uposReplace: {
th: "ks3(金山)",
gat: "不替换",
nor: "不替换",
download: "不替换"
},
bangumiEplist: false,
accessKey: {
token: "",
date: 0,
dateStr: ""
},
watchlater: true,
playlist: true,
ranking: true,
read: true,
search: true,
album: true,
jointime: false,
lostVideo: true,
history: true,
liveRecord: false,
uiEntryType: UiEntryType,
automate: {
danmakuFirst: false,
showBofqi: false,
screenWide: false,
noDanmaku: false,
autoPlay: false,
webFullScreen: false,
videospeed: false
},
videoDisableAA: false,
disableSleepChcek: true,
disableReport: true,
commentJumpUrlTitle: false,
ugcSection: false,
downloadType: ["mp4"],
TVresource: false,
downloadQn: 127,
downloadMethod: "浏览器",
userAgent: "Bilibili Freedoooooom/MarkII",
referer: "https://www.bilibili.com",
filepath: "",
aria2: {
server: "http://localhost",
port: 6800,
token: "",
split: 4,
size: 20
},
ef2: {
delay: false,
silence: false
},
like: false,
bilibiliplayer: true,
checkUpdate: true,
show1080p: false,
fullBannerCover: false,
dmproto: true,
dmwrap: true,
dmExtension: "xml",
dmContact: false,
episodeData: false
};
// src/core/user.ts
var User = class {
constructor(BLOD2) {
this.BLOD = BLOD2;
this.BLOD.GM.getValue("userStatus", userStatus).then((status) => {
status = Object.assign(userStatus, status);
const proxy = propertryChangeHook(status, (key, value) => {
clearTimeout(this.timer);
this.timer = setTimeout(() => this.BLOD.GM.setValue("userStatus", status));
this.emitChange(key, value);
});
this.userStatus = proxy;
this.initialized = true;
while (this.BLOD.userLoadedCallbacks.length) {
this.BLOD.userLoadedCallbacks.shift()?.(this.userStatus);
}
});
}
userStatus;
initialized = false;
updating;
changes = {};
timer;
bindChange(key, callback) {
this.changes[key] || (this.changes[key] = []);
const id = this.changes[key].push(callback);
return () => {
delete this.changes[key][id - 1];
};
}
emitChange(key, newValue) {
this.changes[key].forEach(async (d) => {
d(newValue);
});
}
addCallback(callback) {
if (typeof callback === "function") {
if (this.initialized) {
callback(this.userStatus);
} else {
this.BLOD.userLoadedCallbacks.push(callback);
}
}
}
restoreUserStatus() {
this.BLOD.GM.deleteValue("userStatus");
this.BLOD.toast.warning("已恢复默认设置数据,请刷新页面以避免数据紊乱!");
}
outputUserStatus() {
this.BLOD.GM.getValue("userStatus", userStatus).then((d) => {
saveAs(JSON.stringify(d, void 0, " "), \`Bilibili-Old-\${timeFormat(void 0, true).replace(/ |:/g, (d2) => "-")}\`, "application/json");
});
}
inputUserStatus() {
const msg = ["请选择一个备份的数据文件(.json)", "注意:无效的数据文件可能导致异常!"];
const toast = this.BLOD.toast.toast(0, "warning", ...msg);
fileRead("application/json").then((d) => {
if (d && d[0]) {
msg.push(\`读取文件:\${d[0].name}\`);
toast.data = msg;
toast.type = "info";
return readAs(d[0]).then((d2) => {
const data = JSON.parse(d2);
if (typeof data === "object") {
this.BLOD.GM.setValue("userStatus", data);
const text = "已恢复设置数据,请刷新页面以避免数据紊乱!";
msg.push(text);
toast.data = msg;
toast.type = "success";
return alert(text, "刷新页面", [{
text: "刷新",
callback: () => location.reload()
}]);
}
}).catch((e) => {
msg.push("读取文件出错!", e);
toast.data = msg;
toast.type = "error";
debug.error("恢复设置数据", e);
});
}
}).catch((e) => {
msg.push(e);
toast.data = msg;
}).finally(() => {
toast.delay = 4;
});
}
};
// src/utils/abv.ts
var Abv = class {
base58Table = "fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF";
digitMap = [11, 10, 3, 8, 4, 6];
xor = 177451812;
add = 8728348608;
bvidTemplate = ["B", "V", 1, "", "", 4, "", 1, "", 7, "", ""];
table = {};
constructor() {
for (let i = 0; i < 58; i++)
this.table[this.base58Table[i]] = i;
}
check(input) {
if (/^[aA][vV][0-9]+\$/.test(String(input)) || /^\\d+\$/.test(String(input)))
return this.avToBv(Number(/[0-9]+/.exec(String(input))[0]));
if (/^1[fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF]{9}\$/.test(String(input)))
return this.bvToAv("BV" + input);
if (/^[bB][vV]1[fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF]{9}\$/.test(String(input)))
return this.bvToAv(String(input));
throw input;
}
bvToAv(BV) {
let r = 0;
for (let i = 0; i < 6; i++)
r += this.table[BV[this.digitMap[i]]] * 58 ** i;
return r - this.add ^ this.xor;
}
avToBv(av) {
let bv = Array.from(this.bvidTemplate);
av = (av ^ this.xor) + this.add;
for (let i = 0; i < 6; i++)
bv[this.digitMap[i]] = this.base58Table[parseInt(String(av / 58 ** i)) % 58];
return bv.join("");
}
};
function abv(input) {
return new Abv().check(input);
}
function BV2avAll(str) {
return str.replace(/[bB][vV]1[fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF]{9}/g, (s) => "av" + abv(s));
}
// src/utils/format/url.ts
var URL2 = class {
hash;
base;
params = {};
get param() {
return Object.entries(this.params).reduce((s, d) => {
return s += \`\${s ? "&" : ""}\${d[0]}=\${d[1]}\`;
}, "");
}
constructor(url) {
const arr1 = url.split("#");
let str = arr1.shift();
this.hash = arr1.join("#");
(this.hash || url.includes("#")) && (this.hash = \`#\${this.hash}\`);
const arr2 = str.split("?");
this.base = arr2.shift();
str = arr2.join("?");
if (str) {
str.split("&").forEach((d) => {
const arr3 = d.split("=");
const key = arr3.shift();
let value = arr3.join("=") || "";
try {
if (!isNumber(value)) {
value = JSON.parse(value);
}
} catch {
value === "undefined" && (value = void 0);
value === "NaN" && (value = NaN);
}
this.params[key] = value;
});
}
}
sort() {
this.params = Object.keys(this.params).sort().reduce((s, d) => {
s[d] = this.params[d];
return s;
}, {});
}
toJSON() {
return \`\${this.base ? this.param ? this.base + "?" : this.base : ""}\${this.param}\${this.hash || ""}\`;
}
};
function objUrl(url, obj) {
const res = new URL2(url);
Object.entries(obj).forEach((d) => {
if (d[1] === void 0 || d[1] === null)
return;
res.params[d[0]] = d[1];
});
return res.toJSON();
}
function urlObj(url) {
const res = new URL2(url);
return res.params;
}
// src/core/url.ts
var paramsSet = /* @__PURE__ */ new Set([
"spm_id_from",
"from_source",
"msource",
"bsource",
"seid",
"source",
"session_id",
"visit_id",
"sourceFrom",
"from_spmid",
"share_source",
"share_medium",
"share_plat",
"share_session_id",
"share_tag",
"unique_k",
"vd_source",
"csource"
]);
var paramArr = Object.entries({
from: ["search"]
});
var UrlCleaner = class {
paramsSet = paramsSet;
paramArr = paramArr;
constructor() {
this.location();
window.navigation?.addEventListener("navigate", (e) => {
const newURL = this.clear(e.destination.url);
if (e.destination.url != newURL) {
e.preventDefault();
if (newURL == window.location.href)
return;
this.updateLocation(newURL);
}
});
window.addEventListener("click", (e) => this.anchorClick(e));
window.addEventListener("contextmenu", (e) => this.anchorClick(e));
document.addEventListener("DOMContentLoaded", () => {
this.location();
this.anchor(document.querySelectorAll("a"));
}, { once: true });
}
clear(str) {
const url = new URL2(str);
if (url && !str.includes("passport.bilibili.com")) {
const params = url.params;
if (params.bvid) {
params.aid = abv(params.bvid);
}
if (params.aid && !Number(params.aid)) {
params.aid = abv(params.aid);
}
paramsSet.forEach((d) => {
delete params[d];
});
paramArr.forEach((d) => {
if (params[d[0]]) {
if (d[1].includes(params[d[0]])) {
delete params[d[0]];
}
}
});
url.base = BV2avAll(url.base);
url.hash && (url.hash = BV2avAll(url.hash));
return url.toJSON();
} else
return str;
}
location() {
this.updateLocation(this.clear(location.href));
}
updateLocation(url) {
const Url = new self.URL(url);
if (Url.host === location.host) {
window.history.replaceState(window.history.state, "", url);
}
}
anchorClick(e) {
var f = e.target;
for (; f && "A" !== f.tagName; ) {
f = f.parentNode;
}
if ("A" !== f?.tagName) {
return;
}
this.anchor([f]);
}
anchor(list) {
list.forEach((d) => {
if (!d.href)
return;
d.href = this.clear(d.href);
});
}
};
// src/utils/htmlvnode.ts
var Vnode = class {
tagName;
props = {};
children = [];
text;
constructor(tagName) {
this.tagName = tagName;
}
};
var Scanner = class {
html;
pos = 0;
vnode = [];
tagNames = [];
targets = [];
text = "";
quote = "";
constructor(html) {
this.html = html;
this.targets.push({ children: this.vnode });
while (this.html) {
this.organizeTag();
}
this.textContent();
}
organizeTag() {
if (!this.quote && this.html[0] === "<") {
if (this.html.startsWith(\`\${this.tagNames.reduce((s, d) => s = d, void 0)}\`)) {
this.textContent();
this.html = this.html.replace(new RegExp(\`^\${this.tagNames.reduce((s, d) => s = d, void 0)}>\`), "");
this.popNode();
} else {
this.removeScanned();
if (this.html.startsWith("!-- ")) {
this.html = this.html.replace(/^!--[\\S\\s]+?-->/, "");
}
if (/^[a-zA-Z]/.test(this.html)) {
this.textContent();
const func = [];
let stop = false;
for (this.pos = 0; this.pos < this.html.length; this.pos++) {
if (stop) {
this.pos--;
break;
}
switch (this.html[this.pos]) {
case " ":
case "\\r":
case "\\n":
func.push(() => this.organizeProp());
stop = true;
break;
case ">":
this.html[this.pos - 1] === "/" ? func.push(() => this.popNode()) : func.push(() => this.tagSingle());
stop = true;
break;
}
}
const tagName = this.html.substring(0, this.pos);
const tag = new Vnode(tagName);
this.tagNames.push(tagName);
this.targets.reduce((s, d) => s = d, void 0).children.push(tag);
this.targets.push(tag);
this.removeScanned(this.pos + 1);
func.forEach((d) => d());
}
}
} else {
switch (this.html[0]) {
case "'":
!this.quote ? this.quote = "'" : this.quote === "'" && (this.quote = "");
break;
case '"':
!this.quote ? this.quote = '"' : this.quote === '"' && (this.quote = "");
break;
case "\`":
!this.quote ? this.quote = "\`" : this.quote === "\`" && (this.quote = "");
break;
}
this.text += this.html[0];
this.removeScanned();
}
}
organizeProp() {
let value = false;
let stop = false;
let start = 0;
let popd = false;
for (this.pos = 0; this.pos < this.html.length; this.pos++) {
if (stop)
break;
switch (this.html[this.pos]) {
case '"':
value = !value;
break;
case " ":
if (!value) {
const str = this.html.substring(start, this.pos).replace(/\\r|\\n|"/g, "").replace(/^ +/, "");
const prop = str.split("=");
const key = prop.shift();
key && key !== "/" && (this.targets.reduce((s, d) => s = d, void 0).props[key] = prop.join("=") || key);
start = this.pos;
}
break;
case ">":
if (!value) {
stop = true;
const str = this.html.substring(start, this.pos).replace(/\\r|\\n|"/g, "").replace(/^ +/, "");
const prop = str.split("=");
const key = prop.shift();
key && key !== "/" && (this.targets.reduce((s, d) => s = d, void 0).props[key] = prop.join("=") || key);
if (this.html[this.pos - 1] === "/") {
this.popNode();
popd = true;
}
}
break;
}
}
if (!popd)
this.tagSingle();
this.removeScanned(this.pos--);
}
tagSingle() {
switch (this.tagNames.reduce((s, d) => s = d, void 0)) {
case "area":
case "base":
case "br":
case "col":
case "colgroup":
case "command":
case "embed":
case "hr":
case "img":
case "input":
case "keygen":
case "link":
case "meta":
case "param":
case "path":
case "source":
case "track":
case "wbr":
this.popNode();
break;
}
}
popNode() {
this.tagNames.splice(this.tagNames.length - 1, 1);
this.targets.splice(this.targets.length - 1, 1);
this.text = "";
}
removeScanned(length = 1) {
this.html = this.html.slice(length);
}
textContent() {
const text = this.text.replace(/\\r|\\n| /g, "");
if (text) {
const tag = new Vnode("text");
tag.text = this.text;
this.targets.reduce((s, d) => s = d, void 0).children.push(tag);
}
this.text = "";
}
};
function htmlVnode(html) {
return new Scanner(html).vnode;
}
// src/utils/vdomtool.ts
var VdomTool = class {
vdom;
script = [];
constructor(html) {
if (typeof html === "string") {
this.vdom = htmlVnode(html);
} else {
this.vdom = html;
}
}
toFragment() {
const fragment = document.createDocumentFragment();
this.vdom.forEach((d) => {
if (d.tagName === "script") {
this.script.push(d);
} else
fragment.appendChild(this.createElement(d));
});
return fragment;
}
createElement(element) {
if (element.tagName === "text") {
return document.createTextNode(element.text);
}
if (element.tagName === "svg") {
return this.createSVG(element);
}
const node = document.createElement(element.tagName);
element.props && Object.entries(element.props).forEach((d) => {
node.setAttribute(d[0], d[1]);
});
element.text && node.appendChild(document.createTextNode(element.text));
element.event && Object.entries(element.event).forEach((d) => {
node.addEventListener(...d);
});
element.children && element.children.forEach((d) => {
if (d.tagName === "script") {
this.script.push(d);
} else
node.appendChild(this.createElement(d));
});
return node;
}
createSVG(element) {
const node = document.createElementNS("http://www.w3.org/2000/svg", element.tagName);
element.props && Object.entries(element.props).forEach((d) => {
node.setAttribute(d[0], d[1]);
});
element.children && element.children.forEach((d) => {
node.appendChild(this.createSVG(d));
});
return node;
}
static loopScript(scripts) {
return new Promise((r, j) => {
const prev = scripts.shift();
if (prev) {
if (prev.src) {
prev.addEventListener("load", () => r(this.loopScript(scripts)));
prev.addEventListener("abort", () => r(this.loopScript(scripts)));
prev.addEventListener("error", () => r(this.loopScript(scripts)));
return document.body.appendChild(prev);
}
document.body.appendChild(prev);
r(this.loopScript(scripts));
} else
r();
});
}
loadScript() {
const scripts = this.script.map((d) => this.createElement(d));
return VdomTool.loopScript(scripts);
}
appendTo(node) {
node.append(this.toFragment());
}
replace(node) {
node.replaceWith(this.toFragment());
}
addEventListener(target, type, listener) {
try {
const arr2 = target.split("");
let dom = this.vdom;
let ele;
while (dom && arr2.length) {
const i = Number(arr2.shift());
if (i) {
ele = dom[i];
dom = ele.children;
}
}
ele.event || (ele.event = {});
ele.event[type] = listener;
} catch (e) {
debug.error(e);
}
}
removeEventListener(target, type) {
try {
const arr2 = target.split("");
let dom = this.vdom;
let ele;
while (dom && arr2.length) {
const i = Number(arr2.shift());
if (i) {
ele = dom[i];
dom = ele.children;
}
}
delete ele.event?.[type];
} catch (e) {
debug.error(e);
}
}
};
// src/page/page.ts
var Page = class {
vdom;
initilized = false;
constructor(html) {
this.vdom = new VdomTool(html);
Reflect.defineProperty(window, "_babelPolyfill", {
configurable: true,
set: () => true,
get: () => void 0
});
}
updateDom() {
const title = document.title;
this.vdom.replace(document.documentElement);
Reflect.deleteProperty(window, "PlayerAgent");
Reflect.deleteProperty(window, "webpackJsonp");
this.vdom.loadScript().then(() => this.loadedCallback());
title && !title.includes("404") && (document.title = title);
}
loadedCallback() {
this.initilized = true;
poll(() => document.readyState === "complete", () => {
document.querySelector("#jvs-cert") || window.dispatchEvent(new ProgressEvent("load"));
});
}
};
// src/html/index.html
var html_default = '\\r\\n\\r\\n\\r\\n\\r\\n \\r\\n 哔哩哔哩 (゜-゜)つロ 干杯~-bilibili\\r\\n \\r\\n \\r\\n \\r\\n \\r\\n \\r\\n \\r\\n \\r\\n\\r\\n\\r\\n\\r\\n \\r\\n \\r\\n \\r\\n