>> 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";
init_tampermonkey();
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";
init_tampermonkey();
module2.exports = require_index_light();
}
});
// src/index.ts
init_tampermonkey();
// src/core/bilibili-old.ts
init_tampermonkey();
var BLOD = new class {
/** 路径拆分 */
path = location.href.split("/");
/** bangumi标记 */
pgc = false;
ui;
get aid() {
return window.aid;
}
set aid(v) {
window.aid = v;
}
get cid() {
return window.cid;
}
set cid(v) {
window.cid = v;
}
/** bangumi ssid */
ssid;
/** bangumi epid */
epid;
/** 限制视频 */
limit;
/** 东南亚视频标记 */
th;
/** 播放器已加载 */
playLoaded = false;
/** 已模拟APP端取流 */
networkMocked = false;
/** 是否大会员 */
isVip = false;
/** 播放器哈希值 */
version;
}();
// src/core/user.ts
init_tampermonkey();
// src/utils/debug.ts
init_tampermonkey();
// src/utils/format/time.ts
init_tampermonkey();
// src/utils/format/integer.ts
init_tampermonkey();
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 = (/* @__PURE__ */ 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
init_tampermonkey();
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/core/toast.ts
init_tampermonkey();
// src/html/toast.html
var toast_default = '\\r\\n\\r\\n';
// src/utils/svg.ts
init_tampermonkey();
// 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/svg/left.svg
var left_default = '';
// src/svg/right.svg
var right_default = '';
// src/svg/net.svg
var net_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,
left: left_default,
right: right_default,
net: net_default
};
// src/utils/type.ts
init_tampermonkey();
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/utils/typeof.ts
init_tampermonkey();
var isArray = Array.isArray;
var isObject = (val) => val !== null && typeof val === "object";
var isNumber = (val) => !isNaN(parseFloat(val)) && isFinite(val);
// 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-\${"9c7ff17"}\`) || customElements.define(\`toast-\${"9c7ff17"}\`, 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 toast2 = new Toast();
toast2.type = type;
toast2.rtl = this.rtl;
this.container.insertBefore(toast2, this.container.firstChild);
toast2.data = data;
toast2.delay = delay;
return toast2;
}
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-\${"9c7ff17"}\`) || customElements.define(\`toast-container-\${"9c7ff17"}\`, ToastContainer);
var toast = new ToastContainer();
// src/core/userstatus.ts
init_tampermonkey();
// src/core/ui/entry.ts
init_tampermonkey();
// 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-9c7ff17") || customElements.define("bilibili-entry-9c7ff17", BilioldEntry);
// src/core/userstatus.ts
var userStatus = {
/** 开发者模式 */
development: true,
/** 主页 */
index: true,
/** toastr */
toast: Toastconfig,
/** 替换全局顶栏 */
header: true,
/** 翻页评论区 */
comment: true,
/** av */
av: true,
/** 嵌入式播放器 */
player: true,
/** WebRTC */
webRTC: false,
/** 充电鸣谢 */
elecShow: true,
/** 合作UP */
staff: false,
/** bangumi */
bangumi: true,
/** 解除限制 */
videoLimit: {
/** 开关 */
status: false,
/** 服务器类型 */
server: "内置",
/** 东南亚(泰区)代理服务器 */
th: "api.global.bilibili.com",
/** 台湾代理服务器 */
tw: "",
/** 香港代理服务器 */
hk: "",
/** 大陆代理服务器 */
cn: ""
},
/** UPOS替换 */
uposReplace: {
/** 东南亚(泰区) */
th: "ks3(金山)",
/** 港澳台 */
gat: "不替换",
/** 一般视频 */
nor: "不替换",
/** 下载 */
download: "不替换"
},
/** 强制显示bangumi分p */
bangumiEplist: false,
/** 账户授权 */
accessKey: {
/** access_key */
token: void 0,
/** 授权日期 */
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: "浏览器",
/** User-Agent */
userAgent: "Bilibili Freedoooooom/MarkII",
/** referer */
referer: "https://www.bilibili.com",
/** 下载目录 */
filepath: "",
/** aria2 */
aria2: {
/** 服务器 */
server: "http://localhost",
/** 端口 */
port: 6800,
/** 令牌 */
token: "",
/** 分片数目 */
split: 4,
/** 分片大小 */
size: 20
},
ef2: {
/** 稍后下载 */
delay: false,
/** 静默下载 */
silence: false
},
/** 点赞功能 */
like: false,
/** 重构播放器脚本 */
bilibiliplayer: true,
/** 检查播放器脚本更新 */
checkUpdate: true,
/** 不登录1080P支持 */
show1080p: false,
/** 调整顶栏banner样式 */
fullBannerCover: false,
/** 原生播放器新版弹幕 */
dmproto: true,
/** 普权弹幕换行 */
dmwrap: true,
/** 弹幕格式 */
dmExtension: "xml",
/** 合并已有弹幕 */
dmContact: false,
/** 分集数据 */
episodeData: false,
/** 港澳台新番时间表 */
timeLine: false,
/** 字幕:繁 -> 简 */
simpleChinese: true,
/** 资源cdn */
cdn: "jsdelivr",
/** 弹幕保护计划 */
danmakuProtect: false,
/** 下载按钮 */
downloadButton: false,
/** 全区域搜索 */
searchAllArea: false
};
// src/core/ui/alert.ts
init_tampermonkey();
// src/utils/element.ts
init_tampermonkey();
// src/utils/poll.ts
init_tampermonkey();
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/core/ui/utils/button.ts
init_tampermonkey();
// 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-\${"9c7ff17"}\`) || customElements.define(\`button-\${"9c7ff17"}\`, PushButton);
// src/core/ui/utils/popupbox.ts
init_tampermonkey();
// src/html/popupbox.html
var popupbox_default = '\\r\\n';
// 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-\${"9c7ff17"}\`) || customElements.define(\`popupbox-\${"9c7ff17"}\`, PopupBox);
// src/core/ui/alert.ts
function alert(msg, title, buttons, fork = false) {
isArray(msg) || (msg = [msg]);
msg = msg.join("");
const popup = new PopupBox();
popup.fork = fork;
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/utils/hook/method.ts
init_tampermonkey();
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/core/user.ts
var User = class {
/** 用户数据,除非确定已初始化,否则请使用\`addCallback\`用户数据回调代替 */
userStatus;
/** 初始化标记 */
initialized = false;
/** 更新CD */
updating;
/** 回调栈 */
changes = {};
/** 更新存储延时 */
timer;
/** 用户数据加载回调序列 */
userLoadedCallbacks = [];
constructor() {
GM.getValue("userStatus", userStatus).then((status) => {
status = Object.assign(userStatus, status);
const proxy = propertryChangeHook(status, (key, value) => {
clearTimeout(this.timer);
this.timer = setTimeout(() => GM.setValue("userStatus", status));
this.emitChange(key, value);
});
this.userStatus = proxy;
this.initialized = true;
while (this.userLoadedCallbacks.length) {
this.userLoadedCallbacks.shift()?.(proxy);
}
});
}
/**
* 监听设置改动
* @param key 设置键
* @param callback 设置项变动时执行的回调,新值将作为第一个参数传入
* @returns 用于取消监听的回调
*/
bindChange(key, callback) {
this.changes[key] || (this.changes[key] = []);
const id = this.changes[key].push(callback);
return () => {
delete this.changes[key][id - 1];
};
}
/**
* 推送设置改动
* @param key 设置键
* @param newValue 新值
*/
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.userLoadedCallbacks.push(callback);
}
}
}
/** 恢复默认数据 */
restoreUserStatus() {
GM.deleteValue("userStatus");
toast.warning("已恢复默认设置数据,请刷新页面以避免数据紊乱!");
}
/** 备份设置数据 */
outputUserStatus() {
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 tst = toast.toast(0, "warning", ...msg);
fileRead("application/json").then((d) => {
if (d && d[0]) {
msg.push(\`读取文件:\${d[0].name}\`);
tst.data = msg;
tst.type = "info";
return readAs(d[0]).then((d2) => {
const data = JSON.parse(d2);
if (typeof data === "object") {
GM.setValue("userStatus", data);
const text = "已恢复设置数据,请刷新页面以避免数据紊乱!";
msg.push(text);
tst.data = msg;
tst.type = "success";
return alert(text, "刷新页面", [{
text: "刷新",
callback: () => location.reload()
}]);
}
}).catch((e) => {
msg.push("读取文件出错!", e);
tst.data = msg;
tst.type = "error";
debug.error("恢复设置数据", e);
});
}
}).catch((e) => {
msg.push(e);
tst.data = msg;
}).finally(() => {
tst.delay = 4;
});
}
};
var user = new User();
// src/core/storage.ts
init_tampermonkey();
var LocalStorage = class {
/** 清空! */
static clear() {
localStorage.clear();
}
/**
* 读取
* @param key 目标键名
* @returns 格式化后的数据
*/
static getItem(key) {
return toObject(localStorage.getItem(key));
}
/**
* 列出键名数组
* 原生Storage.key只返回但索引,感觉意义不大。
* @returns 键名数组
*/
static keys() {
return Object.keys(localStorage);
}
/**
* 移除
* @param key 目标键名
*/
static removeItem(key) {
localStorage.removeItem(key);
}
/**
* 添加/修改
* @param key
* @param value
*/
static setItem(key, value) {
localStorage.setItem(key, toString(value));
}
};
var SessionStorage = class {
/** 清空! */
static clear() {
sessionStorage.clear();
}
/**
* 读取
* @param key 目标键名
* @returns 格式化后的数据
*/
static getItem(key) {
return toObject(sessionStorage.getItem(key));
}
/**
* 列出键名数组
* 原生Storage.key只返回但索引,感觉意义不大。
* @returns 键名数组
*/
static keys() {
return Object.keys(sessionStorage);
}
/**
* 移除
* @param key 目标键名
*/
static removeItem(key) {
sessionStorage.removeItem(key);
}
/**
* 添加/修改
* @param key
* @param value
*/
static setItem(key, value) {
sessionStorage.setItem(key, toString(value));
}
};
// src/page/header.ts
init_tampermonkey();
// src/io/api-page-header.ts
init_tampermonkey();
// src/utils/format/url.ts
init_tampermonkey();
var URL2 = class {
/** 锚 */
hash;
/** 基链 */
base;
/** 参数对象。结果会格式化\`undefined\`\`null\`\`NaN\`等特殊值,但不会处理数字,以免丢失精度。 */
params = {};
/** 参数链(不含\`?\`) */
get param() {
return Object.entries(this.params).reduce((s, d) => {
return s += \`\${s ? "&" : ""}\${d[0]}=\${d[1]}\`;
}, "");
}
/** 提取URL参数 */
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();
if (key) {
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;
}, {});
}
/** 还原url链接 */
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/io/api.ts
init_tampermonkey();
var import_md5 = __toESM(require_md5());
function jsonCheck(str) {
const result = typeof str === "string" ? JSON.parse(str) : str;
if (result.code === 0)
return result;
throw new Error(\`\${result.code} \${result.message}\`, { cause: result.code });
}
var APP_KEY = /* @__PURE__ */ ((APP_KEY2) => {
APP_KEY2["1d8b6e7d45233436"] = "560c52ccd288fed045859ed18bffd973";
APP_KEY2["c1b107428d337928"] = "ea85624dfcf12d7cc7b2b3a94fac1f2c";
APP_KEY2["07da50c9a0bf829f"] = "25bdede4e1581c836cab73a48790ca6e";
APP_KEY2["7d089525d3611b1c"] = "acd495b248ec528c2eed1e862d393126";
APP_KEY2["9e5ded06c39bf5c4"] = "583e398ed0f980290b5903aba30b4cc4";
APP_KEY2["27eb53fc9058f8c3"] = "c2ed53a74eeefe3cf99fbd01d8c9c375";
APP_KEY2["85eb6835b0a1034e"] = "2ad42749773c441109bdc0191257a664";
APP_KEY2["4409e2ce8ffd12b8"] = "59b43e04ad6965f34319062b478f83dd";
APP_KEY2["37207f2beaebf8d7"] = "e988e794d4d4b6dd43bc0e89d6e90c43";
APP_KEY2["84956560bc028eb7"] = "94aba54af9065f71de72f5508f1cd42e";
APP_KEY2["bb3101000e232e27"] = "36efcfed79309338ced0380abd824ac1";
APP_KEY2["fb06a25c6338edbc"] = "fd10bd177559780c2e4a44f1fa47fa83";
APP_KEY2["iVGUTjsxvpLeuDCf"] = "aHRmhWMLkdeMuILqORnYZocwMBpMEOdt";
APP_KEY2["178cf125136ca8ea"] = "34381a26236dd1171185c0beb042e1c6";
APP_KEY2["57263273bc6b67f6"] = "a0488e488d1567960d3a765e8d129f90";
APP_KEY2["8d23902c1688a798"] = "710f0212e62bd499b8d3ac6e1db9302a";
APP_KEY2["7d336ec01856996b"] = "a1ce6983bc89e20a36c37f40c4f1a0dd";
APP_KEY2["8e16697a1b4f8121"] = "f5dd03b752426f2e623d7badb28d190a";
APP_KEY2["aae92bc66f3edfab"] = "af125a0d5279fd576c1b4418a3e8276d";
APP_KEY2["ae57252b0c09105d"] = "c75875c596a69eb55bd119e74b07cfe3";
APP_KEY2["bca7e84c2d947ac6"] = "60698ba2f68e01ce44738920a0ffe768";
APP_KEY2["cc578d267072c94d"] = "ffb6bb4c4edae2566584dbcacfc6a6ad";
APP_KEY2["cc8617fd6961e070"] = "3131924b941aac971e45189f265262be";
APP_KEY2["YvirImLGlLANCLvM"] = "JNlZNgfNGKZEpaDTkCdPQVXntXhuiJEM";
APP_KEY2["f3bb208b3d081dc8"] = "f7c926f549b9becf1c27644958676a21";
APP_KEY2["4fa4601d1caa8b48"] = "f7c926f549b9becf1c27644958676a21";
APP_KEY2["452d3958f048c02a"] = "f7c926f549b9becf1c27644958676a21";
APP_KEY2["86385cdc024c0f6c"] = "f7c926f549b9becf1c27644958676a21";
APP_KEY2["5256c25b71989747"] = "f7c926f549b9becf1c27644958676a21";
APP_KEY2["e97210393ad42219"] = "f7c926f549b9becf1c27644958676a21";
APP_KEY2["5dce947fe22167f9"] = "";
APP_KEY2["8e9fc618fbd41e28"] = "";
APP_KEY2["21087a09e533a072"] = "e5b8ba95cab6104100be35739304c23a";
return APP_KEY2;
})(APP_KEY || {});
var ApiSign = class {
constructor(url, appkey) {
this.url = url;
this.appkey = appkey;
}
get ts() {
return (/* @__PURE__ */ new Date()).getTime();
}
/** 查询参数,须要在子类中初始化好才能无参数调用\`sign\`方法 */
data = {};
/**
* URL签名
* @param searchParams 查询参数,会覆盖url原有参数
* @param api 授权api,**授权第三方登录专用**
* @returns 签名后的api
*/
sign(searchParams = this.data, api = "") {
const url = new URL2(this.url);
Object.assign(url.params, searchParams, { ts: this.ts });
delete url.params.sign;
api && (this.appkey = "27eb53fc9058f8c3");
const appSecret = this.appSecret;
url.params.appkey = this.appkey;
url.sort();
url.params.sign = (0, import_md5.default)((api ? \`api=\${decodeURIComponent(api)}\` : url.param) + appSecret);
return url.toJSON();
}
get appSecret() {
switch (this.appkey) {
case "f3bb208b3d081dc8":
case "4fa4601d1caa8b48":
case "452d3958f048c02a":
case "86385cdc024c0f6c":
case "5256c25b71989747":
case "e97210393ad42219":
switch (Math.trunc((/* @__PURE__ */ new Date()).getHours() / 4)) {
case 0:
this.appkey = "f3bb208b3d081dc8";
break;
case 1:
this.appkey = "4fa4601d1caa8b48";
break;
case 2:
this.appkey = "452d3958f048c02a";
break;
case 3:
this.appkey = "86385cdc024c0f6c";
break;
case 4:
this.appkey = "5256c25b71989747";
break;
case 5:
this.appkey = "e97210393ad42219";
break;
default:
break;
}
break;
default:
break;
}
return APP_KEY[this.appkey];
}
};
// src/io/urls.ts
init_tampermonkey();
var _URLS = class {
};
var URLS = _URLS;
// protocol + //
__publicField(URLS, "P_AUTO", "//");
__publicField(URLS, "P_HTTP", "http://");
__publicField(URLS, "P_HTTPS", "https://");
__publicField(URLS, "P_WS", "ws://");
__publicField(URLS, "P_WSS", "wss://");
// domain
__publicField(URLS, "D_WWW", "www.bilibili.com");
__publicField(URLS, "D_API", "api.bilibili.com");
__publicField(URLS, "D_APP", "app.bilibili.com");
__publicField(URLS, "D_MANAGER", "manager.bilibili.co");
__publicField(URLS, "D_INTERFACE", "interface.bilibili.com");
__publicField(URLS, "D_PASSPORT", "passport.bilibili.com");
__publicField(URLS, "D_BANGUMI", "bangumi.bilibili.com");
__publicField(URLS, "D_SPACE", "space.bilibili.com");
__publicField(URLS, "D_STATIC_S", "static.hdslb.com");
__publicField(URLS, "D_CHAT", "chat.bilibili.com");
__publicField(URLS, "D_DATA", "data.bilibili.com");
__publicField(URLS, "D_COMMENT", "comment.bilibili.com");
__publicField(URLS, "D_BROADCAST", "broadcast.bilibili.com");
__publicField(URLS, "D_MISAKA_SW", "misaka-sw.bilibili.com");
__publicField(URLS, "D_MEMBER", "member.bilibili.com");
__publicField(URLS, "D_BVC", "bvc.bilivideo.com");
__publicField(URLS, "D_S1", "s1.hdslb.com");
__publicField(URLS, "D_API_GLOBAL", "api.global.bilibili.com");
__publicField(URLS, "D_ACCOUNT", "account.bilibili.com");
__publicField(URLS, "D_INTL", "apiintl.biliapi.net");
__publicField(URLS, "WEBSHOW_LOCS", _URLS.P_AUTO + _URLS.D_API + "/x/web-show/res/locs");
__publicField(URLS, "INDEX_TOP_RCMD", _URLS.P_AUTO + _URLS.D_API + "/x/web-interface/index/top/rcmd");
__publicField(URLS, "PAGE_HEADER", _URLS.P_AUTO + _URLS.D_API + "/x/web-show/page/header");
__publicField(URLS, "SEASON_RANK_LIST", _URLS.P_AUTO + _URLS.D_API + "/pgc/season/rank/web/list");
__publicField(URLS, "VIDEO", _URLS.P_AUTO + _URLS.D_STATIC_S + "/js/video.min.js");
__publicField(URLS, "JQUERY", _URLS.P_AUTO + _URLS.D_STATIC_S + "/js/jquery.min.js");
__publicField(URLS, "ARTICLE_CARDS", _URLS.P_AUTO + _URLS.D_API + "/x/article/cards");
__publicField(URLS, "VIEW_DETAIL", _URLS.P_AUTO + _URLS.D_API + "/x/web-interface/view/detail");
__publicField(URLS, "VIEW", _URLS.P_AUTO + _URLS.D_API + "/view");
__publicField(URLS, "X_VIEW", _URLS.P_AUTO + _URLS.D_API + "/x/web-interface/view");
__publicField(URLS, "PAGE_LIST", _URLS.P_AUTO + _URLS.D_API + "/x/player/pagelist");
__publicField(URLS, "TAG_INFO", _URLS.P_AUTO + _URLS.D_API + "/x/tag/info");
__publicField(URLS, "TAG_TOP", _URLS.P_AUTO + _URLS.D_API + "/x/web-interface/tag/top");
__publicField(URLS, "BANGUMI_SEASON", _URLS.P_AUTO + _URLS.D_BANGUMI + "/view/web_api/season");
__publicField(URLS, "SEASON_STATUS", _URLS.P_AUTO + _URLS.D_API + "/pgc/view/web/season/user/status");
__publicField(URLS, "SEASON_SECTION", _URLS.P_AUTO + _URLS.D_API + "/pgc/web/season/section");
__publicField(URLS, "GLOBAL_OGV_VIEW", _URLS.P_AUTO + _URLS.D_API_GLOBAL + "/intl/gateway/v2/ogv/view/app/season");
__publicField(URLS, "GLOBAL_OGV_PLAYURL", _URLS.P_AUTO + _URLS.D_API_GLOBAL + "/intl/gateway/v2/ogv/playurl");
__publicField(URLS, "APP_PGC_PLAYURL", _URLS.P_AUTO + _URLS.D_API + "/pgc/player/api/playurl");
__publicField(URLS, "ACCOUNT_GETCARDBYMID", _URLS.P_AUTO + _URLS.D_ACCOUNT + "/api/member/getCardByMid");
__publicField(URLS, "LOGIN_APP_THIRD", _URLS.P_AUTO + _URLS.D_PASSPORT + "/login/app/third");
__publicField(URLS, "PLAYER", _URLS.P_AUTO + _URLS.D_API + "/x/player/v2");
__publicField(URLS, "PLAYURL_PROJ", _URLS.P_AUTO + _URLS.D_APP + "/v2/playurlproj");
__publicField(URLS, "PGC_PLAYURL_PROJ", _URLS.P_AUTO + _URLS.D_API + "/pgc/player/api/playurlproj");
__publicField(URLS, "PGC_PLAYURL_TV", _URLS.P_AUTO + _URLS.D_API + "/pgc/player/api/playurltv");
__publicField(URLS, "UGC_PLAYURL_TV", _URLS.P_AUTO + _URLS.D_API + "/x/tv/ugc/playurl");
__publicField(URLS, "PGC_PLAYURL", _URLS.P_AUTO + _URLS.D_API + "/pgc/player/web/playurl");
__publicField(URLS, "PLAYURL", _URLS.P_AUTO + _URLS.D_API + "/x/player/playurl");
__publicField(URLS, "INTL_PLAYURL", _URLS.P_AUTO + _URLS.D_APP + "/x/intl/playurl");
__publicField(URLS, "INTL_OGV_PLAYURL", _URLS.P_AUTO + _URLS.D_INTL + "/intl/gateway/ogv/player/api/playurl");
__publicField(URLS, "PLAYURL_INTERFACE", _URLS.P_AUTO + _URLS.D_INTERFACE + "/v2/playurl");
__publicField(URLS, "PLAYURL_BANGUMI", _URLS.P_AUTO + _URLS.D_BANGUMI + "/player/web_api/v2/playurl");
__publicField(URLS, "LIKE", _URLS.P_AUTO + _URLS.D_API + "/x/web-interface/archive/like");
__publicField(URLS, "HAS_LIKE", _URLS.P_AUTO + _URLS.D_API + "/x/web-interface/archive/has/like");
__publicField(URLS, "DM_WEB_VIEW", _URLS.P_AUTO + _URLS.D_API + "/x/v2/dm/web/view");
__publicField(URLS, "DM_WEB_SEG_SO", _URLS.P_AUTO + _URLS.D_API + "/x/v2/dm/web/seg.so");
__publicField(URLS, "STAT", _URLS.P_AUTO + _URLS.D_API + "/x/web-interface/archive/stat");
__publicField(URLS, "SLIDE_SHOW", _URLS.P_AUTO + _URLS.D_API + "/pgc/operation/api/slideshow");
__publicField(URLS, "SEARCH_SQUARE", _URLS.P_AUTO + _URLS.D_API + "/x/web-interface/search/square");
__publicField(URLS, "SPACE_ARC", _URLS.P_AUTO + _URLS.D_API + "/x/space/wbi/arc/search");
__publicField(URLS, "NEWLIST", _URLS.P_AUTO + _URLS.D_API + "/x/web-interface/newlist");
__publicField(URLS, "SEARCH", _URLS.P_AUTO + _URLS.D_API + "/search");
// src/io/api-page-header.ts
async function apiPageHeader(data) {
const response = await fetch(objUrl(URLS.PAGE_HEADER, data));
const json = await response.json();
return jsonCheck(json).data;
}
// src/utils/conf/uid.ts
init_tampermonkey();
// src/utils/cookie.ts
init_tampermonkey();
function getCookies() {
return document.cookie.split("; ").reduce((s, d) => {
let key = d.split("=")[0];
let val = d.split("=")[1];
s[key] = unescape(val);
return s;
}, {});
}
function setCookie(name, value, days = 365) {
const exp = /* @__PURE__ */ new Date();
exp.setTime(exp.getTime() + days * 24 * 60 * 60 * 1e3);
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toUTCString() + "; path=/; domain=.bilibili.com";
}
// src/utils/conf/uid.ts
var uid = Number(getCookies().DedeUserID);
// src/utils/format/subarray.ts
init_tampermonkey();
function subArray(res, num = 1) {
const arr2 = [...res];
const out = [];
num = num || 1;
num = num < arr2.length ? num : arr2.length;
while (out.length < num) {
var temp = Math.random() * arr2.length >> 0;
out.push(arr2.splice(temp, 1)[0]);
}
return num === 1 ? out[0] : out;
}
// src/utils/hook/node.ts
init_tampermonkey();
var appendChild = Element.prototype.appendChild;
var insertBefore = Element.prototype.insertBefore;
var jsonp = [];
Element.prototype.appendChild = function(newChild) {
this.parentElement === document.documentElement && newChild.nodeName == "SCRIPT" && newChild.src && jsonp.forEach((d) => {
d[0].every((d2) => newChild.src.includes(d2)) && d[1].call(newChild);
});
return appendChild.call(this, newChild);
};
Element.prototype.insertBefore = function(newChild, refChild) {
this.parentElement === document.documentElement && newChild.nodeName == "SCRIPT" && newChild.src && jsonp.forEach((d) => {
d[0].every((d2) => newChild.src.includes(d2)) && d[1].call(newChild);
});
return insertBefore.call(this, newChild, refChild);
};
function jsonpHook(url, redirect, modifyResponse, once = true) {
let id;
const one = Array.isArray(url) ? url : [url];
const two = function() {
once && id && delete jsonp[id - 1];
if (redirect)
try {
this.src = redirect(this.src) || this.src;
} catch (e) {
debug.error("redirect of jsonphook", one, e);
}
if (modifyResponse) {
const obj = urlObj(this.src);
if (obj) {
const callback = obj.callback;
const call = window[callback];
const url2 = this.src;
if (call) {
window[callback] = function(v) {
try {
v = modifyResponse(v, url2, call) || v;
} catch (e) {
debug.error("modifyResponse of jsonphook", one, e);
}
return v !== true && call(v);
};
}
}
}
};
const iid = jsonp.push([one, two]);
return () => {
removeJsonphook(iid);
};
}
jsonpHook.async = (url, condition, modifyResponse, once = true) => {
let id;
const one = Array.isArray(url) ? url : [url];
const two = function() {
try {
once && id && delete jsonp[id - 1];
if (!condition || condition(this.src)) {
const obj = urlObj(this.src);
if (obj) {
const callback = obj.callback;
const call = window[callback];
if (call) {
modifyResponse && modifyResponse(this.src).then((d) => {
window[callback](d);
this.dispatchEvent(new ProgressEvent("load"));
}).catch((e) => {
this.dispatchEvent(new ProgressEvent("error"));
debug.error("modifyResponse of xhrhookasync", one, e);
});
}
this.removeAttribute("src");
}
}
} catch (e) {
debug.error("jsonphook", one, e);
}
};
const iid = jsonp.push([one, two]);
return () => {
removeJsonphook(iid);
};
};
jsonpHook.scriptBlock = (url) => {
const one = Array.isArray(url) ? url : [url];
const two = function() {
try {
this.removeAttribute("src");
setTimeout(() => {
this.dispatchEvent(new ProgressEvent("load"));
try {
this.remove();
} catch (e) {
}
}, 100);
} catch (e) {
debug.error("脚本拦截失败!", one, e);
}
};
jsonp.push([one, two]);
};
jsonpHook.scriptIntercept = (url, redirect, text) => {
const one = Array.isArray(url) ? url : [url];
const two = function() {
try {
if (text) {
this.text = text(this.src);
this.removeAttribute("src");
setTimeout(() => {
this.dispatchEvent(new ProgressEvent("load"));
this?.remove();
}, 100);
} else if (redirect) {
this.src = redirect(this.src);
}
} catch (e) {
debug.error("scriptIntercept", one, e);
}
};
const iid = jsonp.push([one, two]);
return () => {
removeJsonphook(iid);
};
};
function removeJsonphook(id) {
id >= 0 && delete jsonp[id - 1];
}
// src/utils/hook/xhr.ts
init_tampermonkey();
var rules = [];
var open = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(...rest) {
const args = [...rest];
args[1] && rules.forEach((d) => {
d && d[0].every((d2) => args[1].includes(d2)) && d[1].call(this, args);
});
return open.call(this, ...args);
};
function xhrHook(url, modifyOpen, modifyResponse, once = true) {
let id;
const one = Array.isArray(url) ? url : [url];
const two = function(args) {
once && id && delete rules[id - 1];
if (modifyOpen)
try {
modifyOpen(args);
} catch (e) {
debug.error("modifyOpen of xhrhook", one, e);
}
if (modifyResponse)
try {
this.addEventListener("readystatechange", () => {
try {
if (this.readyState === 4) {
const response = { response: this.response, responseType: this.responseType, status: this.status, statusText: this.statusText };
(this.responseType === "" || this.responseType === "text") && (response.responseText = this.responseText);
(this.responseType === "" || this.responseType === "document") && (response.responseXML = this.responseXML);
modifyResponse(response);
Reflect.defineProperty(this, "response", { configurable: true, value: response.response });
response.responseText && Reflect.defineProperty(this, "responseText", { configurable: true, value: response.responseText });
response.responseXML && Reflect.defineProperty(this, "responseXML", { configurable: true, value: response.responseXML });
}
} catch (e) {
debug.error("modifyResponse of xhrhook", one, e);
}
});
} catch (e) {
debug.error("modifyResponse of xhrhook", one, e);
}
};
const iid = rules.push([one, two]);
return () => {
removeXhrhook(iid);
};
}
xhrHook.async = (url, condition, modifyResponse, once = true) => {
let id, temp;
const one = Array.isArray(url) ? url : [url];
const two = function(args) {
try {
if (!condition || condition(args)) {
this.xhrhookTimes = this.xhrhookTimes ? this.xhrhookTimes++ : 1;
id && (temp = rules[id - 1]);
delete rules[id - 1];
this.send = () => true;
(!args[2] || args[2] === true) && (this.timeout = 0);
const et = setInterval(() => {
this.dispatchEvent(new ProgressEvent("progress"));
}, 50);
Reflect.defineProperty(this, "status", { configurable: true, value: 200 });
Reflect.defineProperty(this, "readyState", { configurable: true, value: 2 });
this.dispatchEvent(new ProgressEvent("readystatechange"));
modifyResponse ? modifyResponse(args).then((d) => {
clearInterval(et);
if (d) {
Reflect.defineProperty(this, "response", { configurable: true, value: d.response });
d.responseType && setResponseType(d.responseType, this);
d.responseText && Reflect.defineProperty(this, "responseText", { configurable: true, value: d.responseText });
d.responseXML && Reflect.defineProperty(this, "responseXML", { configurable: true, value: d.responseXML });
!this.responseURL && Reflect.defineProperty(this, "responseURL", { configurable: true, value: args[1] });
Reflect.defineProperty(this, "readyState", { configurable: true, value: 4 });
this.dispatchEvent(new ProgressEvent("readystatechange"));
this.dispatchEvent(new ProgressEvent("load"));
this.dispatchEvent(new ProgressEvent("loadend"));
}
}).catch((d) => {
if (this.xhrhookTimes === 1) {
if (d && d.response) {
Reflect.defineProperty(this, "response", { configurable: true, value: d.response });
d.responseType && setResponseType(d.responseType, this);
d.responseText && Reflect.defineProperty(this, "responseText", { configurable: true, value: d.responseText });
d.responseXML && Reflect.defineProperty(this, "responseXML", { configurable: true, value: d.responseXML });
!this.responseURL && Reflect.defineProperty(this, "responseURL", { configurable: true, value: args[1] });
Reflect.defineProperty(this, "readyState", { configurable: true, value: 4 });
this.dispatchEvent(new ProgressEvent("readystatechange"));
this.dispatchEvent(new ProgressEvent("load"));
this.dispatchEvent(new ProgressEvent("loadend"));
} else {
this.dispatchEvent(new ProgressEvent("error"));
}
} else {
this.xhrhookTimes--;
}
debug.error("modifyResponse of xhrhookasync", one, d);
}).finally(() => {
clearInterval(et);
!once && (id = rules.push(temp));
}) : (this.abort(), !once && (id = rules.push(temp)));
clearInterval(et);
}
} catch (e) {
debug.error("condition of xhrhook", one, e);
}
};
const iid = rules.push([one, two]);
return () => {
removeXhrhook(iid);
};
};
function removeXhrhook(id) {
id >= 0 && delete rules[id - 1];
}
xhrHook.ultra = (url, modify) => {
const one = Array.isArray(url) ? url : [url];
const two = function(args) {
try {
modify.call(this, this, args);
} catch (e) {
debug.error("xhrhook modify", one, modify, e);
}
};
const iid = rules.push([one, two]);
return () => {
removeXhrhook(iid);
};
};
function setResponseType(responseType, xhr) {
Reflect.defineProperty(xhr, "responseType", { configurable: true, value: responseType });
xhr.getResponseHeader = (name) => {
if (name === "content-type") {
switch (xhr.responseType) {
case "arraybuffer":
case "blob":
return "application/octet-stream";
case "document":
return "text/xml; charset=utf-8";
case "json":
return "application/json; charset=utf-8";
default:
return "text/plain; charset=utf-8";
}
}
return "text/plain; charset=utf-8";
};
xhr.getAllResponseHeaders = () => {
switch (xhr.responseType) {
case "arraybuffer":
case "blob":
return "content-type: application/octet-stream\\r\\n";
case "document":
return "content-type: text/xml; charset=utf-8\\r\\n";
case "json":
return "content-type: application/json; charset=utf-8\\r\\n";
default:
return "content-type: text/plain; charset=utf-8\\r\\n";
}
};
}
// src/css/avatar-animation.css
var avatar_animation_default = "/* 鼠标放在顶栏上的动效 */\\r\\n.bili-header-m .profile-info .i-face .face {\\r\\n border: 0\\r\\n}\\r\\n\\r\\n.bili-header-m .profile-info .i-face .pendant {\\r\\n transform: scale(0.5);\\r\\n width: 112px;\\r\\n height: 112px;\\r\\n left: -41px;\\r\\n bottom: -46px;\\r\\n opacity: 0;\\r\\n transition: opacity .1s ease-in\\r\\n}\\r\\n\\r\\n.bili-header-m .profile-info.on .i-face {\\r\\n left: 8px !important;\\r\\n top: 0 !important;\\r\\n height: 32px !important;\\r\\n width: 32px !important;\\r\\n transform: translateY(10px) translateX(-16px) scale(2);\\r\\n transform-origin: top left\\r\\n}\\r\\n\\r\\n.bili-header-m .profile-info.on .i-face .legalize {\\r\\n transform: scale(0.5) translate(10px, 15px)\\r\\n}\\r\\n\\r\\n.bili-header-m .profile-info.on .i-face .pendant {\\r\\n opacity: 1\\r\\n}\\r\\n\\r\\n.bili-header-m .profile-info.on .i-face .face {\\r\\n border: 0;\\r\\n box-shadow: 0 0 0 2px #fff\\r\\n}\\r\\n\\r\\n.bili-header-m .profile-info.on .i-face.scale-in {\\r\\n transform: translateY(5px) translateX(-10px) scale(1.75)\\r\\n}\\r\\n\\r\\n.bili-header-m .profile-info.on .scale-in .face {\\r\\n height: 32px;\\r\\n width: 32px\\r\\n}\\r\\n\\r\\n.bili-header-m .profile-info.on .i-face.scale-in .legalize {\\r\\n transform: scale(0.5) translate(38px, 48px)\\r\\n}";
// src/css/message.css
var message_default = "/* 修复消息页样式 */\\r\\n.container[data-v-6969394c] {\\r\\n height: calc(100vh - 42px) !important;\\r\\n}\\r\\n\\r\\n.container[data-v-1c9150a9] {\\r\\n height: calc(100vh - 42px) !important;\\r\\n}\\r\\n\\r\\n.im-root,\\r\\n.im-root .im-list-box * {\\r\\n font-size: 12px;\\r\\n line-height: 42px;\\r\\n}\\r\\n\\r\\n.im-root .im-list-box {\\r\\n width: 100%;\\r\\n overflow: visible;\\r\\n}\\r\\n\\r\\n.im-root .im-list-box .im-list {\\r\\n line-height: 42px;\\r\\n height: 42px;\\r\\n}\\r\\n\\r\\n.im-root .im-list-box .im-notify.im-number {\\r\\n height: 14px;\\r\\n line-height: 13px;\\r\\n border-radius: 10px;\\r\\n padding: 1px 3px;\\r\\n font-size: 12px;\\r\\n min-width: 20px;\\r\\n text-align: center;\\r\\n color: #fff;\\r\\n}\\r\\n\\r\\n.im-root .im-list-box .im-notify.im-number.im-center {\\r\\n top: 14px;\\r\\n left: 80px;\\r\\n}\\r\\n\\r\\n.im-root .im-list-box .im-notify.im-dot {\\r\\n top: 11px;\\r\\n right: -10px;\\r\\n width: 8px;\\r\\n height: 8px;\\r\\n border-radius: 100%;\\r\\n}\\r\\n\\r\\n.im-root .im-list-box .im-notify.im-dot.im-center {\\r\\n top: 16px;\\r\\n right: 20px;\\r\\n}";
// src/page/header.ts
var _Header = class {
/**
* 根据页面返回resourceId
* @returns resourceId
*/
static resourceId() {
if (location.href.includes("v/douga"))
return 1576;
if (location.href.includes("/anime"))
return 1612;
if (location.href.includes("v/music"))
return 1580;
if (location.href.includes("/guochuang"))
return 1920;
if (location.href.includes("v/dance"))
return 1584;
if (location.href.includes("v/game"))
return 1588;
if (location.href.includes("v/knowledge"))
return 1592;
if (location.href.includes("v/tech"))
return 3129;
if (location.href.includes("v/life"))
return 1600;
if (location.href.includes("v/kichiku"))
return 1608;
if (location.href.includes("v/fashion"))
return 1604;
if (location.href.includes("v/ent"))
return 1596;
if (location.href.includes("v/cinephile"))
return 2210;
if (location.href.includes("/cinema"))
return 1634;
return 142;
}
/** 顶栏分区 */
static primaryMenu() {
poll(() => document.querySelector("#primary_menu"), (d) => {
const vue = d.__vue__;
vue.menuList.forEach((d2, i, s) => {
switch (d2.name) {
case "动画":
s[i].sub = [{ "name": "MAD·AMV", "route": "mad", "tid": 24, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 151 }, "desc": "具有一定制作程度的动画或静画的二次创作视频", "url": "//www.bilibili.com/video/douga-mad-1.html" }, { "name": "MMD·3D", "route": "mmd", "tid": 25, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 152 }, "desc": "使用MMD(MikuMikuDance)和其他3D建模类软件制作的视频", "url": "//www.bilibili.com/video/douga-mmd-1.html" }, { "name": "短片·手书·配音", "route": "voice", "tid": 47, "ps": 15, "rps": 10, "desc": "追求创新并具有强烈特色的短片、手书(绘)及ACG相关配音", "url": "//www.bilibili.com/video/douga-voice-1.html" }, { "name": "手办·模玩", "route": "garage_kit", "tid": 210, "ps": 15, "rps": 10, "desc": "手办模玩的测评、改造或其他衍生内容", "url": "" }, { "name": "特摄", "route": "tokusatsu", "tid": 86, "ps": 15, "rps": 10, "desc": "特摄相关衍生视频", "url": "//www.bilibili.com/video/cinephile-tokusatsu.html" }, { "name": "综合", "route": "other", "tid": 27, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 153 }, "desc": "以动画及动画相关内容为素材,包括但不仅限于音频替换、杂谈、排行榜等内容", "url": "//www.bilibili.com/video/douga-else-1.html" }];
break;
case "音乐":
s[i].sub = [{ "name": "原创音乐", "route": "original", "tid": 28, "ps": 15, "rps": 10, "viewHotTag": true, "ad": { "active": true, "dataLocId": 243 }, "dpConfig": [{ "name": "一日", "value": 1 }, { "name": "三日", "value": 3 }], "desc": "原创歌曲及纯音乐,包括改编、重编曲及remix", "url": "//www.bilibili.com/video/music-original-1.html" }, { "name": "翻唱", "route": "cover", "tid": 31, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 245 }, "viewHotTag": true, "dpConfig": [{ "name": "一日", "value": 1 }, { "name": "三日", "value": 3 }], "desc": "对曲目的人声再演绎视频", "url": "//www.bilibili.com/video/music-Cover-1.html" }, { "name": "演奏", "route": "perform", "tid": 59, "ps": 15, "rps": 10, "viewHotTag": true, "dpConfig": [{ "name": "一日", "value": 1 }, { "name": "三日", "value": 3 }], "desc": "乐器和非传统乐器器材的演奏作品", "url": "//www.bilibili.com/video/music-perform-1.html" }, { "name": "VOCALOID·UTAU", "route": "vocaloid", "tid": 30, "ps": 15, "rps": 10, "viewHotTag": true, "ad": { "active": true, "dataLocId": 247 }, "dpConfig": [{ "name": "一日", "value": 1 }, { "name": "三日", "value": 3 }], "desc": "以VOCALOID等歌声合成引擎为基础,运用各类音源进行的创作", "url": "//www.bilibili.com/video/music-vocaloid-1.html" }, { "name": "音乐现场", "route": "live", "tid": 29, "ps": 15, "rps": 10, "viewHotTag": true, "dpConfig": [{ "name": "一日", "value": 1 }, { "name": "三日", "value": 3 }], "desc": "音乐表演的实况视频,包括官方/个人拍摄的综艺节目、音乐剧、音乐节、演唱会等", "url": "//www.bilibili.com/video/music-oped-1.html" }, { "name": "MV", "route": "mv", "tid": 193, "ps": 15, "rps": 10, "viewHotTag": true, "dpConfig": [{ "name": "一日", "value": 1 }, { "name": "三日", "value": 3 }], "desc": "为音乐作品配合拍摄或制作的音乐录影带(Music Video),以及自制拍摄、剪辑、翻拍MV", "url": "//www.bilibili.com/video/music-coordinate-1.html" }, { "name": "乐评盘点", "route": "commentary", "tid": 243, "ps": 15, "rps": 10, "viewHotTag": true, "dpConfig": [{ "name": "一日", "value": 1 }, { "name": "三日", "value": 3 }], "desc": "音乐类新闻、盘点、点评、reaction、榜单、采访、幕后故事、唱片开箱等", "url": "//www.bilibili.com/video/music-collection-1.html" }, { "name": "音乐教学", "route": "tutorial", "tid": 244, "ps": 15, "rps": 10, "viewHotTag": true, "dpConfig": [{ "name": "一日", "value": 1 }, { "name": "三日", "value": 3 }], "desc": "以音乐教学为目的的内容", "url": "//www.bilibili.com/video/music-collection-1.html" }, { "name": "音乐综合", "route": "other", "tid": 130, "ps": 15, "rps": 10, "viewHotTag": true, "dpConfig": [{ "name": "一日", "value": 1 }, { "name": "三日", "value": 3 }], "desc": "所有无法被收纳到其他音乐二级分区的音乐类视频", "url": "//www.bilibili.com/video/music-collection-1.html" }, { "name": "音频", "customZone": "Audio", "route": "audio", "url": "//www.bilibili.com/audio/home?musicType=music" }, { "name": "说唱", "url": "//www.bilibili.com/v/rap" }];
break;
case "科技":
s[i].name = "知识";
s[i].route = "knowledge";
s[i].sub = [{ "name": "科学科普", "route": "science", "tid": 201, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 261 }, "desc": "回答你的十万个为什么" }, { "name": "社科·法律·心理", "route": "social_science", "tid": 124, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 263 }, "desc": "基于社会科学、法学、心理学展开或个人观点输出的知识视频" }, { "name": "人文历史", "route": "humanity_history", "tid": 228, "ps": 15, "rps": 10, "desc": "看看古今人物,聊聊历史过往,品品文学典籍" }, { "name": "财经商业", "route": "business", "tid": 207, "ps": 15, "rps": 10, "desc": "说金融市场,谈宏观经济,一起畅聊商业故事" }, { "name": "校园学习", "route": "campus", "tid": 208, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 265 }, "desc": "老师很有趣,学生也有才,我们一起搞学习" }, { "name": "职业职场", "route": "career", "tid": 209, "ps": 15, "rps": 10, "desc": "职业分享、升级指南,一起成为最有料的职场人" }, { "name": "设计·创意", "route": "design", "tid": 229, "ps": 15, "rps": 10, "desc": "天马行空,创意设计,都在这里" }, { "name": "野生技能协会", "route": "skill", "tid": 122, "ps": 15, "rps": 10, "desc": "技能党集合,是时候展示真正的技术了" }];
break;
case "数码":
s[i].name = "科技";
s[i].route = "tech";
s[i].sub = [{ "name": "数码", "route": "digital", "tid": 95, "ps": 15, "rps": 10, "viewHotTag": true, "desc": "科技数码产品大全,一起来做发烧友", "url": "#" }, { "name": "软件应用", "route": "application", "tid": 230, "ps": 15, "rps": 10, "viewHotTag": true, "desc": "超全软件应用指南", "url": "#" }, { "name": "计算机技术", "route": "computer_tech", "tid": 231, "ps": 15, "rps": 10, "viewHotTag": true, "desc": "研究分析、教学演示、经验分享......有关计算机技术的都在这里", "url": "#" }, { "name": "科工机械", "route": "industry", "tid": 232, "ps": 15, "rps": 10, "viewHotTag": true, "desc": "从小芯片到大工程,一起见证科工力量", "url": "#" }, { "name": "极客DIY", "route": "diy", "tid": 233, "ps": 15, "rps": 10, "viewHotTag": true, "desc": "炫酷技能,极客文化,硬核技巧,准备好你的惊讶", "url": "#" }];
break;
case "生活":
s[i].sub = [{ "name": "搞笑", "route": "funny", "tid": 138, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 273 }, "desc": "各种沙雕有趣的搞笑剪辑,挑战,表演,配音等视频", "url": "//www.bilibili.com/video/ent_funny_1.html", "locid": 4204, "recommendId": 4210, "slider": { "width": 620, "height": 220 }, "customComponent": { "name": "Energy", "leftId": 4212, "rightId": 4218, "rightType": "slide" } }, { "name": "家居房产", "route": "home", "tid": 239, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 275 }, "desc": "与买房、装修、居家生活相关的分享", "url": "#" }, { "name": "手工", "route": "handmake", "tid": 161, "ps": 15, "rps": 10, "desc": "手工制品的制作过程或成品展示、教程、测评类视频", "url": "//www.bilibili.com/video/ent-handmake-1.html" }, { "name": "绘画", "route": "painting", "tid": 162, "ps": 15, "rps": 10, "desc": "绘画过程或绘画教程,以及绘画相关的所有视频", "url": "//www.bilibili.com/video/ent-painting-1.html" }, { "name": "日常", "route": "daily", "tid": 21, "ps": 15, "rps": 10, "desc": "记录日常生活,分享生活故事", "url": "//www.bilibili.com/video/ent-life-1.html" }];
break;
case "鬼畜":
s[i].sub = [{ "name": "鬼畜调教", "route": "guide", "tid": 22, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 285 }, "desc": "使用素材在音频、画面上做一定处理,达到与BGM一定的同步感", "url": "//www.bilibili.com/video/ent-Kichiku-1.html" }, { "name": "音MAD", "route": "mad", "tid": 26, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 287 }, "desc": "使用素材音频进行一定的二次创作来达到还原原曲的非商业性质稿件", "url": "//www.bilibili.com/video/douga-kichiku-1.html" }, { "name": "人力VOCALOID", "route": "manual_vocaloid", "tid": 126, "ps": 15, "rps": 10, "desc": "将人物或者角色的无伴奏素材进行人工调音,使其就像VOCALOID一样歌唱的技术", "url": "//www.bilibili.com/video/kichiku-manual_vocaloid-1.html" }, { "name": "鬼畜剧场", "route": "theatre", "tid": 216, "ps": 15, "rps": 10, "desc": "使用素材进行人工剪辑编排的有剧情的作品" }, { "name": "教程演示", "route": "course", "tid": 127, "ps": 10, "rps": 6, "rightComponent": { "name": "CmImgList", "id": 148 }, "ad": { "active": true, "dataLocId": 289 }, "hideDropdown": false, "desc": "鬼畜相关的教程演示", "url": "//www.bilibili.com/video/kichiku-course-1.html" }];
break;
case "时尚":
s[i].sub = [{ "name": "美妆护肤", "route": "makeup", "tid": 157, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 279 }, "desc": "彩妆护肤、美甲美发、仿妆、医美相关内容分享或产品测评", "url": "//www.bilibili.com/video/fashion-makeup-fitness-1.html" }, { "name": "穿搭", "route": "clothing", "tid": 158, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 281 }, "desc": "穿搭风格、穿搭技巧的展示分享,涵盖衣服、鞋靴、箱包配件、配饰(帽子、钟表、珠宝首饰)等", "url": "//www.bilibili.com/video/fashion-clothing-1.html" }, { "name": "时尚潮流", "route": "trend", "tid": 159, "ps": 15, "rps": 10, "desc": "时尚街拍、时装周、时尚大片,时尚品牌、潮流等行业相关记录及知识科普", "url": "#" }];
break;
case "广告":
s[i].name = "资讯";
s[i].route = "information";
s[i].tid = 202;
s[i].sub = [{ "name": "热点", "route": "hotspot", "tid": 203, "ps": 18, "rps": 10, "desc": "全民关注的时政热门资讯" }, { "name": "环球", "route": "global", "tid": 204, "ps": 18, "rps": 10, "desc": "全球范围内发生的具有重大影响力的事件动态" }, { "name": "社会", "route": "social", "tid": 205, "ps": 18, "rps": 10, "desc": "日常生活的社会事件、社会问题、社会风貌的报道" }, { "name": "综合", "route": "multiple", "tid": 206, "ps": 18, "rps": 10, "desc": "除上述领域外其它垂直领域的综合资讯" }];
break;
case "娱乐":
s[i].sub = [{ "name": "综艺", "route": "variety", "tid": 71, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 267 }, "desc": "所有综艺相关,全部一手掌握!", "url": "//www.bilibili.com/video/ent-variety-1.html" }, { "name": "娱乐杂谈", "route": "talker", "tid": 241, "ps": 15, "rps": 10, "ad": { "active": true, "dataLocId": 269 }, "desc": "娱乐人物解读、娱乐热点点评、娱乐行业分析" }, { "name": "粉丝创作", "route": "fans", "tid": 242, "ps": 15, "rps": 10, "desc": "粉丝向创作视频" }, { "name": "明星综合", "route": "celebrity", "tid": 137, "ps": 15, "rps": 10, "desc": "娱乐圈动态、明星资讯相关" }];
break;
}
});
});
this.plaza();
this.indexIcon();
this.styleFix();
}
static banner() {
jsonpHook.async("api.bilibili.com/x/web-show/res/loc", void 0, async (url) => {
const obj = new URL(url);
obj.searchParams.delete("callback");
let loc = this.record[url];
let header = this.record[this.rid];
let rqs;
if (!loc || !header) {
rqs = await Promise.all([
fetch(obj.toJSON()).then((d) => d.json()),
apiPageHeader({ resource_id: this.rid })
]);
loc = this.record[url] = rqs[0];
header = this.record[this.rid] = rqs[1];
}
loc.data && this.locs.forEach((d) => {
loc.data[d] && (loc.data[d][0].pic = header && header.pic || "//i0.hdslb.com/bfs/activity-plat/static/20171220/68a052f664e8414bb594f9b00b176599/images/90w1lpp6ry.png", loc.data[d][0].litpic = header && header.litpic, loc.data[d][0].url = header && header.url || "", loc.data[d][0].title = header && header.name || "");
if (url.includes("loc?") && obj.searchParams.get("id") == String(d)) {
loc.data[0].pic = header && header.pic || "//i0.hdslb.com/bfs/activity-plat/static/20171220/68a052f664e8414bb594f9b00b176599/images/90w1lpp6ry.png";
loc.data[0].litpic = header && header.litpic || "";
loc.data[0].url = header && header.url || "";
loc.data[0].title = header && header.name || "";
}
});
return loc;
}, false);
}
/** 顶栏广场 */
static plaza() {
jsonpHook.async("api.bilibili.com/plaza/banner", () => true, async () => {
return { "code": 0, "result": [{ "link": "https://www.bilibili.com/blackboard/x/act_list", "end": 1640966407, "begin": 1456709887, "title": "bilibili 活动", "cover": "http://i0.hdslb.com/bfs/square/6830d0e479eee8cc9a42c3e375ca99a5147390cd.jpg", "id": 9, "created_ts": 1491386053 }, { "link": "http://www.bilibili.com/blackboard/topic_list.html", "end": 1640966418, "begin": 1544258598, "title": "话题列表", "cover": "http://i0.hdslb.com/bfs/square/b1b00a0c3ce8570b48277ae07a2e55603a4a4ddf.jpg", "id": 17, "created_ts": 1491386030 }] };
}, false);
}
/** 顶栏动图 */
static indexIcon() {
jsonpHook.async("api.bilibili.com/x/web-interface/index/icon", void 0, async () => {
const data = await fetch("https://www.bilibili.com/index/index-icon.json").then((d) => d.json());
return {
code: 0,
data: subArray(data.fix),
message: "0",
ttl: 1
};
}, false);
}
/** 消息页面样式 */
static message() {
addCss(message_default, "message");
}
/** 顶栏动态记录参数失效,另行找补 */
static videoOffset() {
if (uid) {
const offset2 = getCookies()[\`bp_video_offset_\${uid}\`];
if (offset2) {
setCookie(\`bp_t_offset_\${uid}\`, offset2);
}
}
}
/** 迷你顶栏 */
miniHeader() {
this.oldHeader.classList.remove("has-menu");
}
/** 是否mini顶栏 */
static isMiniHead(d) {
return location.href.includes("blackboard/topic_list") || location.href.includes("blackboard/x/act_list") || document.querySelector(".large-header") || document.querySelector(".bili-banner") || d?.getAttribute("type") == "all" ? false : true;
}
constructor() {
this.oldHeader.className = "z-top-container has-menu";
this.hookHeadV2();
this.feedCount();
poll(() => document.readyState === "complete", () => this.styleClear());
}
/** 监听新版顶栏 */
hookHeadV2() {
poll(() => {
return document.querySelector("#internationalHeader") || document.querySelector("#biliMainHeader") || document.querySelector("#bili-header-container") || document.querySelector("#home_nav") || document.querySelector(".bili-header__bar");
}, (d) => {
_Header.isMiniHead(d) && this.miniHeader();
this.loadOldHeader(d);
});
poll(() => document.querySelector(".z_top_container"), (d) => {
this.loadOldHeader(d);
document.querySelector(".header").style.display = "none";
});
}
/** 已加载旧版顶栏 */
oldHeadLoaded = false;
/** 旧版顶栏节点 */
oldHeader = document.createElement("div");
/** 加载旧版顶栏 */
loadOldHeader(target) {
if (target) {
if (target.className === "bili-header__bar") {
addCss('.bili-header.large-header,.header-channel,.z-top-container.has-menu[type="all"] {display: none;}');
}
document.body.classList.remove("header-v3");
target.style.display = "none";
target.hidden = true;
}
if (this.oldHeadLoaded)
return;
this.oldHeadLoaded = true;
addCss("#internationalHeader,#biliMainHeader,#bili-header-container{display: none;}");
document.body.insertBefore(this.oldHeader, document.body.firstChild);
(window.jQuery ? Promise.resolve() : loadScript("//static.hdslb.com/js/jquery.min.js")).then(() => loadScript("//s1.hdslb.com/bfs/seed/jinkela/header/header.js")).then(() => {
_Header.styleFix();
});
_Header.primaryMenu();
_Header.banner();
}
loadOldFooter(target) {
addElement("div", { class: "footer bili-footer report-wrap-module" }, void 0, void 0, void 0, target);
(window.jQuery ? Promise.resolve() : loadScript("//static.hdslb.com/js/jquery.min.js")).then(() => loadScript("//static.hdslb.com/common/js/footer.js")).then(() => {
target && (target.style.display = "none");
this.styleClear();
addCss(".bili-footer {position: relative;}");
document.getElementsByClassName("bili-header-m")[1]?.remove();
});
}
/** 顶栏样式修复 */
static styleFix() {
addCss(".nav-item.live {width: auto;}.lt-row {display: none !important;} .bili-header-m #banner_link{background-size: cover;background-position: center !important;}", "lt-row-fix");
addCss(avatar_animation_default, "avatarAnimation");
this.fullBannerCover && addCss(".bili-header-m #banner_link{height: 9.375vw !important;min-width: 1000px;min-height: 155px;max-height: 240px;}");
}
/** 禁用新版顶栏相关样式 */
async styleClear() {
const d = document.styleSheets;
for (let i = 0; i < d.length; i++) {
d[i].href?.includes("laputa-header") && (d[i].disabled = true);
}
_Header.styleFix();
}
/** 顶栏动态直播回复数目接口失效,强制标记为0 */
feedCount() {
xhrHook.async("api.live.bilibili.com/ajax/feed/count", void 0, async () => {
const response = '{ "code": 0, "data": { "count": 0 }, "message": "0" }';
return { response, responseText: response };
}, false);
}
};
var Header = _Header;
/** locs列表 */
__publicField(Header, "locs", [1576, 1612, 1580, 1920, 1584, 1588, 1592, 3129, 1600, 1608, 1604, 1596, 2210, 1634, 142]);
/** 缓存已请求内容 */
__publicField(Header, "record", {});
/** 资源id */
__publicField(Header, "rid", _Header.resourceId());
__publicField(Header, "fullBannerCover", false);
// src/page/space.ts
init_tampermonkey();
// src/io/account-getcardbymid.ts
init_tampermonkey();
async function accountGetCardByMid(mid) {
const response = await GM.fetch(objUrl(URLS.ACCOUNT_GETCARDBYMID, { mid }));
const json = await response.json();
return jsonCheck(json).card;
}
// src/json/mid.json
var mid_default = {
code: 0,
data: {
birthday: "1980-01-01",
coins: 0,
face: "http://i2.hdslb.com/bfs/face/9f10323503739e676857f06f5e4f5eb323e9f3f2.jpg",
fans_badge: false,
is_followed: true,
jointime: 1436351229,
level: 6,
mid: 11783021,
moral: 0,
name: "哔哩哔哩番剧出差",
official: {
type: 1,
desc: "哔哩哔哩番剧出差 官方账号"
},
pendant: {
pid: 0,
name: "",
image: "",
expire: 0
},
rank: "10000",
sex: "保密",
sign: "",
silence: 0,
sys_notice: {},
theme: {},
user_honour_info: {
colour: null,
mid: 0,
tags: null
},
vip: {
avatar_subscript: 1,
avatar_subscript_url: "http://i0.hdslb.com/bfs/vip/icon_Certification_big_member_22_3x.png",
due_date: 16557408e5,
label: {
bg_color: "#FB7299",
bg_style: 1,
border_color: "",
label_theme: "annual_vip",
path: "",
text: "年度大会员",
text_color: "#FFFFFF"
},
nickname_color: "#FB7299",
role: 3,
status: 1,
theme_type: 0,
type: 2,
vip_pay_type: 1
}
},
message: "0",
ttl: 1
};
// src/utils/vdomtool.ts
init_tampermonkey();
// src/utils/htmlvnode.ts
init_tampermonkey();
var Vnode = class {
tagName;
props = {};
children = [];
text;
constructor(tagName) {
this.tagName = tagName;
}
};
var Scanner = class {
/** HTML */
html;
/** 当前光标 */
pos = 0;
/** Vnode */
vnode = [];
/** 节点名栈 */
tagNames = [];
/** Vnode栈 */
targets = [];
/** innerText栈 */
text = "";
/** 引号栈 */
quote = "";
/**
* 扫描html文本转化为Vnode
* @param html html文本
*/
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 = "";
}
/** 移除已扫描字符长度 默认1位 */
removeScanned(length2 = 1) {
this.html = this.html.slice(length2);
}
/** 处理TextContent */
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;
}
}
/** 生成 DocumentFragment(会过滤script标签,请稍后使用\`loadScript\`方法依次运行所有script) */
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;
}
/** 根据vdom生成真DOM(过滤script标签) */
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;
}
/** svg限定生成方法 */
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/space.ts
var Mid = {
11783021: "哔哩哔哩番剧出差",
1988098633: "b站_戲劇咖",
2042149112: "b站_綜藝咖"
};
var PageSpace = class {
mid;
/** 失效视频aid */
aids = [];
aidInfo = [];
constructor() {
this.mid = Number(BLOD.path[3] && BLOD.path[3].split("?")[0]);
this.midInfo();
user.addCallback((status) => {
status.album && this.album();
status.jointime && this.jointime();
status.lostVideo && this.lostVideo();
});
}
/** 修复限制访问up空间 */
midInfo() {
switch (this.mid) {
case 11783021:
case 1988098633:
case 2042149112:
mid_default.data.name = Mid[this.mid];
mid_default.data.official.desc = mid_default.data.name + " 官方帐号";
xhrHook("acc/info?", void 0, (obj) => {
if (obj.responseText && obj.responseText.includes("-404")) {
obj.response = obj.responseText = JSON.stringify(mid_default);
toast.warning("该用户被404,已使用缓存数据恢复访问!");
}
}, false);
break;
default:
break;
}
}
/** 还原相簿 */
album() {
xhrHook("api.bilibili.com/x/dynamic/feed/draw/doc_list", void 0, (obj) => {
const response = JSON.parse(obj.responseText);
let data = response.data.items.reduce((s, d) => {
s.push(d.doc_id);
return s;
}, []);
setTimeout(() => {
document.querySelectorAll(".album-card").forEach((d, i) => {
d.firstChild.href = \`//h.bilibili.com/\${data[i]}\`;
d.children[1].href = \`//h.bilibili.com/\${data[i]}\`;
});
}, 1e3);
}, false);
}
/** 动态重定向回相簿 */
static album() {
xhrHook(["x/polymer/web-dynamic", "detail?"], void 0, (res) => {
const result = res.responseType === "json" ? res.response : JSON.parse(res.response);
if (result.code === 0) {
if (result.data?.item.type === "DYNAMIC_TYPE_DRAW")
location.replace(\`https://h.bilibili.com/\${result.data.item.basic.rid_str}\`);
}
}, false);
}
/** 注册时间 */
jointime() {
poll(() => document.querySelector(".section.user-info"), (t) => {
accountGetCardByMid(this.mid).then((d) => {
const jointime = timeFormat(d.regtime * 1e3, true);
const node = t.lastChild;
new VdomTool(\`
注册
\${jointime}
\`).appendTo(node);
});
});
}
/** 失效视频 */
lostVideo() {
xhrHook("x/v3/fav/resource/list", void 0, async (res) => {
try {
const data = jsonCheck(res.response);
if (data.data.medias) {
data.data.medias.forEach((d) => {
d.attr % 2 && this.aids.push(d.id);
});
}
if (this.aids.length) {
const data2 = ["检测到失效视频!", this.aids.join(" ")];
const tst = toast.toast(0, "warning", ...data2);
this.lostVideoView().then(() => {
setTimeout(() => {
data2.push("数据返回,正在修复~");
let resolve = 0, reject = 0;
tst.data = data2;
tst.type = "success";
const ele = document.querySelector("#page-fav");
if (ele) {
const medias = ele.__vue__.favListDetails.medias;
medias?.forEach((d) => {
if (d.attr % 2) {
data2.push(\`-------- av\${d.id} --------\`);
if (this.aidInfo[d.id].title) {
resolve++;
d.title = this.aidInfo[d.id].title;
data2.push(this.aidInfo[d.id].title);
} else {
reject++;
d.title = \`av\${d.id}\`;
data2.push("未能获取到有效信息!");
}
this.aidInfo[d.id].cover && (d.cover = this.aidInfo[d.id].cover);
d.attr = 0;
tst.data = data2;
ele.querySelector(\`[data-aid=\${d.bvid}]\`)?.children[1]?.setAttribute("style", "text-decoration : line-through;color : #ff0000;");
}
});
}
data2.push("", \`修复结束:成功 \${resolve} 失败 \${reject}\`);
tst.data = data2;
tst.delay = 4;
}, 100);
});
}
} catch {
}
}, false);
}
lostVideoView() {
const arr2 = [];
while (this.aids.length) {
arr2.push((async () => {
const d = this.aids.shift();
if (this.aidInfo[d])
return;
let title, cover;
await GM.fetch(\`//www.biliplus.com/video/av\${d}\`).then((d2) => d2.text()).then((d2) => {
if (d2.match(/\\.+?\\ \\-\\ AV/)) {
title = d2.match(/\\.+?\\ \\-\\ AV/)[0].replace(//, "").replace(/ - AV/, "");
cover = d2.match(/\\
{
debug.error(\`获取失效视频av\${d}信息错误\`, "BILIPLUS", e);
});
if (!title || !cover) {
await GM.fetch(\`//www.biliplus.com/all/video/av\${d}\`).then((d2) => d2.text()).then((d2) => {
if (d2.match("/api/view_all?")) {
const url = d2.match(/\\/api\\/view_all\\?.+?\\',cloudmoe/)[0].replace(/\\',cloudmoe/, "");
return GM.fetch(\`//www.biliplus.com\${url}\`);
}
throw new Error("无cid缓存");
}).then((d2) => d2.json()).then((d2) => {
d2 = jsonCheck(d2);
title = title || d2.data.info.title;
cover = cover || d2.data.info.pic;
}).catch((e) => {
debug.error(\`获取失效视频av\${d}信息错误\`, "BILIPLUSALL", e);
});
}
if (!title || !cover) {
await GM.fetch(\`//www.jijidown.com/video/av\${d}\`).then((d2) => d2.text()).then((d2) => {
if (d2.match("window._INIT")) {
title = title || d2.match(/\\.+?\\-哔哩哔哩唧唧/)[0].replace(//, "").replace(/-哔哩哔哩唧唧/, "");
cover = cover || d2.match(/\\"img\\":\\ \\".+?\\",/)[0].match(/http.+?\\",/)[0].replace(/",/, "");
}
}).catch((e) => {
debug.error(\`获取失效视频av\${d}信息错误\`, "JIJIDOWN", e);
});
}
cover = cover && cover.replace("http:", "");
this.aidInfo[d] = { title, cover };
})());
}
return Promise.all(arr2);
}
};
// src/page/media.ts
init_tampermonkey();
var PageMedia = class {
constructor() {
this.limit();
}
/** 解除限制 */
limit() {
xhrHook("user/status", void 0, (res) => {
try {
const result = jsonCheck(res.response);
result.result.area_limit = 0;
result.result.ban_area_show = 0;
res.responseType === "json" ? res.response = result : res.response = res.responseText = JSON.stringify(result);
} catch (e) {
}
}, false);
}
};
// src/page/history.ts
init_tampermonkey();
var PageHistory = class {
constructor() {
user.addCallback((status) => {
status.history && this.archive();
});
}
/** 纯视频历史记录 */
archive() {
xhrHook(["api.bilibili.com/x/web-interface/history/cursor", "business"], function(args) {
let obj = new URL(args[1]), max = obj.searchParams.get("max") || "", view_at = obj.searchParams.get("view_at") || "";
args[1] = objUrl("//api.bilibili.com/x/web-interface/history/cursor", { max, view_at, type: "archive", ps: "20" });
}, void 0, false);
}
};
// src/page/live.ts
init_tampermonkey();
// src/core/report.ts
init_tampermonkey();
var Cache = class {
fpriskMsg = {};
};
var EventTracker = class {
extMsgs = {};
legalContainer = "report-wrap-module";
bindEvent() {
}
bindHeatMapEvent() {
}
checkContainer() {
}
eventCB() {
}
handleSelfDefReport() {
}
todo() {
}
};
var LoadTracker = class {
msg = {};
showRawPerformance() {
}
todo() {
}
};
var PvTracker = class {
extMsgs = {};
_uuid = "";
sendPV() {
}
todo() {
}
};
var ScrollTracker = class {
extMsgs = {};
ignoreHidden = true;
reportedIds = [];
scrollDivClass = "";
scrollLintenerFns = [];
scrollMsg = {};
scrollReportOffset = 200;
scrollSubDivClass = "";
addScrollListenNode() {
}
checkScroll() {
}
customReport() {
}
getOffset() {
}
inView() {
}
judgeAppear() {
}
judgeCustom() {
}
judgeHidden() {
}
judgeSubAppear() {
}
removeScrollListenNode() {
}
subInView() {
}
todo() {
}
todoCustom() {
}
};
var reportConfig = { msgObjects: "spmReportData", sample: -1, scrollTracker: false };
var reportMsgObj = {};
var ReportObserver = class {
constructor() {
propertyHook(window, "reportObserver", this);
propertyHook(window, "reportConfig", reportConfig);
}
cache = new Cache();
eventTracker = new EventTracker();
loadTracker = new LoadTracker();
pvTracker = new PvTracker();
scrollTracker = new ScrollTracker();
forceCommit() {
}
importTracker() {
}
init() {
}
initBsource() {
}
initTracker() {
}
reportCustomData() {
}
reportWithAdditionalParam() {
}
reportWithSpmPrefix() {
}
sendPV() {
}
sendPerformance() {
}
setSPM_id() {
}
setSpeicalMsg() {
}
updateConfig() {
}
};
var statisObserverConfig = {
blackEvents: [],
clickConfig: { logId: "", isDoubleWrite: false },
loadPerform: false,
loadSpecial: false,
performConfig: { isWrite: false },
pvConfig: { isDoubleWrite: false, logId: "", selfDefMsg: {} },
selfConfig: { logId: "", isDoubleWrite: false, isSelfDefWrite: false, isDefaultWrite: false },
spmId: ""
};
var StatisObserver = class {
__bufferFuns = [];
__initConfig = {};
__loadedFlag = { baidu: false, error: false, event: false, perform: false, pv: false, special: false };
__visitId = "";
constructor() {
propertyHook(window, "__statisObserver", this);
propertyHook(window, "reportMsgObj", reportMsgObj);
propertyHook(window, "__statisObserverConfig", statisObserverConfig);
}
addClickTracker() {
}
addLegalContainer() {
}
addSelfDefineMsg() {
}
forceCommit() {
}
getPvid() {
}
removeLegalContainer() {
}
removeSelfDefineMsg() {
}
sendBaidu() {
}
sendClickEvent() {
}
sendCustomMetrics() {
}
sendError() {
}
sendPV() {
}
sendPerform() {
}
sendSpecial() {
}
setAttrName() {
}
setBaseUrl() {
}
setErrorInterval() {
}
setErrorLogId() {
}
setEventLogId() {
}
setEventSendStatus() {
}
setPVLogId() {
}
setPVSendStatus() {
}
setPerformLogId() {
}
setPvid() {
}
setSpecialFirstLoop() {
}
setSpecialInterval() {
}
setSpecialLogId() {
}
setSpmId() {
}
startPoolListen() {
}
startSpecialLoop() {
}
stopPoolListen() {
}
stopSpecialLoop() {
}
};
// src/core/url.ts
init_tampermonkey();
// src/utils/abv.ts
init_tampermonkey();
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;
}
/**
* av/BV互转
* @param input av或BV,可带av/BV前缀
* @returns 转化结果
*/
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/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 });
}
/** 净化url */
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;
}
/** 净化URL */
location() {
this.updateLocation(this.clear(location.href));
}
/** 更新URL而不触发重定向 */
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]);
}
/** 净化a标签 */
anchor(list) {
list.forEach((d) => {
if (!d.href)
return;
d.href = this.clear(d.href);
});
}
};
var urlCleaner = new UrlCleaner();
// src/page/live.ts
var PageLive = class {
sleep = false;
constructor() {
user.addCallback((status) => {
status.disableSleepChcek && this.disAbleSleepCheck();
status.disableReport && new StatisObserver();
});
this.urlClean();
}
/** 添加url清理参数 */
urlClean() {
urlCleaner.paramsSet.add("broadcast_type");
urlCleaner.paramsSet.add("is_room_feed");
}
/** 禁止挂机检测 */
disAbleSleepCheck() {
const setInterval2 = self.setInterval;
self.setInterval = (...args) => {
if (args[0].toString().includes("triggerSleepCallback")) {
if (!this.sleep) {
this.sleep = true;
toast.warning("成功阻止直播间挂机检测!");
}
return Number.MIN_VALUE;
}
return setInterval2.call(self, ...args);
};
}
};
// src/page/dynamic.ts
init_tampermonkey();
var PageDynamic = class {
constructor() {
user.addCallback((status) => {
status.liveRecord || this.liveRecord();
});
}
liveRecord() {
xhrHook("api.bilibili.com/x/polymer/web-dynamic/v1/feed/all", void 0, (r) => {
try {
const response = jsonCheck(r.response);
response.data.items = response.data.items.filter((d) => d.modules?.module_dynamic?.major?.archive?.badge?.text != "直播回放");
r.responseType === "json" ? r.response = response : r.response = r.responseText = JSON.stringify(response);
} catch (e) {
}
}, false);
}
};
// src/page/index.ts
init_tampermonkey();
// 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