// ==UserScript== // @name Bilibili 旧播放页 // @namespace MotooriKashin // @version 10.0.2-e6541bd8837e5835f288e9e9dec3c645e0b39e8a // @description 恢复Bilibili旧版页面,为了那些念旧的人。 // @author MotooriKashin, wly5556 // @homepage https://github.com/MotooriKashin/Bilibili-Old // @supportURL https://github.com/MotooriKashin/Bilibili-Old/issues // @icon https://www.bilibili.com/favicon.ico // @match *://*.bilibili.com/* // @connect * // @grant GM.xmlHttpRequest // @grant GM.getValue // @grant GM.setValue // @grant GM.deleteValue // @grant GM.cookie // @run-at document-start // @license MIT // @downloadURL none // ==/UserScript== const MODULES = ` var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; // node_modules/crypt/crypt.js var require_crypt = __commonJS({ "node_modules/crypt/crypt.js"(exports, module) { (function() { var base64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", crypt = { rotl: function(n, b) { return n << b | n >>> 32 - b; }, rotr: function(n, b) { return n << 32 - b | n >>> b; }, endian: function(n) { if (n.constructor == Number) { return crypt.rotl(n, 8) & 16711935 | crypt.rotl(n, 24) & 4278255360; } for (var i = 0; i < n.length; i++) n[i] = crypt.endian(n[i]); return n; }, randomBytes: function(n) { for (var bytes = []; n > 0; n--) bytes.push(Math.floor(Math.random() * 256)); return bytes; }, bytesToWords: function(bytes) { for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8) words[b >>> 5] |= bytes[i] << 24 - b % 32; return words; }, wordsToBytes: function(words) { for (var bytes = [], b = 0; b < words.length * 32; b += 8) bytes.push(words[b >>> 5] >>> 24 - b % 32 & 255); return bytes; }, bytesToHex: function(bytes) { for (var hex = [], i = 0; i < bytes.length; i++) { hex.push((bytes[i] >>> 4).toString(16)); hex.push((bytes[i] & 15).toString(16)); } return hex.join(""); }, hexToBytes: function(hex) { for (var bytes = [], c = 0; c < hex.length; c += 2) bytes.push(parseInt(hex.substr(c, 2), 16)); return bytes; }, bytesToBase64: function(bytes) { for (var base64 = [], i = 0; i < bytes.length; i += 3) { var triplet = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2]; for (var j = 0; j < 4; j++) if (i * 8 + j * 6 <= bytes.length * 8) base64.push(base64map.charAt(triplet >>> 6 * (3 - j) & 63)); else base64.push("="); } return base64.join(""); }, base64ToBytes: function(base64) { base64 = base64.replace(/[^A-Z0-9+\\/]/ig, ""); for (var bytes = [], i = 0, imod4 = 0; i < base64.length; imod4 = ++i % 4) { if (imod4 == 0) continue; bytes.push((base64map.indexOf(base64.charAt(i - 1)) & Math.pow(2, -2 * imod4 + 8) - 1) << imod4 * 2 | base64map.indexOf(base64.charAt(i)) >>> 6 - imod4 * 2); } return bytes; } }; module.exports = crypt; })(); } }); // node_modules/charenc/charenc.js var require_charenc = __commonJS({ "node_modules/charenc/charenc.js"(exports, module) { var charenc = { utf8: { stringToBytes: function(str) { return charenc.bin.stringToBytes(unescape(encodeURIComponent(str))); }, bytesToString: function(bytes) { return decodeURIComponent(escape(charenc.bin.bytesToString(bytes))); } }, bin: { stringToBytes: function(str) { for (var bytes = [], i = 0; i < str.length; i++) bytes.push(str.charCodeAt(i) & 255); return bytes; }, bytesToString: function(bytes) { for (var str = [], i = 0; i < bytes.length; i++) str.push(String.fromCharCode(bytes[i])); return str.join(""); } } }; module.exports = charenc; } }); // node_modules/is-buffer/index.js var require_is_buffer = __commonJS({ "node_modules/is-buffer/index.js"(exports, module) { module.exports = function(obj) { return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer); }; function isBuffer(obj) { return !!obj.constructor && typeof obj.constructor.isBuffer === "function" && obj.constructor.isBuffer(obj); } function isSlowBuffer(obj) { return typeof obj.readFloatLE === "function" && typeof obj.slice === "function" && isBuffer(obj.slice(0, 0)); } } }); // node_modules/md5/md5.js var require_md5 = __commonJS({ "node_modules/md5/md5.js"(exports, module) { (function() { var crypt = require_crypt(), utf8 = require_charenc().utf8, isBuffer = require_is_buffer(), bin = require_charenc().bin, md52 = function(message, options) { if (message.constructor == String) if (options && options.encoding === "binary") message = bin.stringToBytes(message); else message = utf8.stringToBytes(message); else if (isBuffer(message)) message = Array.prototype.slice.call(message, 0); else if (!Array.isArray(message) && message.constructor !== Uint8Array) message = message.toString(); var m = crypt.bytesToWords(message), l = message.length * 8, a = 1732584193, b = -271733879, c = -1732584194, d = 271733878; for (var i = 0; i < m.length; i++) { m[i] = (m[i] << 8 | m[i] >>> 24) & 16711935 | (m[i] << 24 | m[i] >>> 8) & 4278255360; } m[l >>> 5] |= 128 << l % 32; m[(l + 64 >>> 9 << 4) + 14] = l; var FF = md52._ff, GG = md52._gg, HH = md52._hh, II = md52._ii; for (var i = 0; i < m.length; i += 16) { var aa = a, bb = b, cc = c, dd = d; a = FF(a, b, c, d, m[i + 0], 7, -680876936); d = FF(d, a, b, c, m[i + 1], 12, -389564586); c = FF(c, d, a, b, m[i + 2], 17, 606105819); b = FF(b, c, d, a, m[i + 3], 22, -1044525330); a = FF(a, b, c, d, m[i + 4], 7, -176418897); d = FF(d, a, b, c, m[i + 5], 12, 1200080426); c = FF(c, d, a, b, m[i + 6], 17, -1473231341); b = FF(b, c, d, a, m[i + 7], 22, -45705983); a = FF(a, b, c, d, m[i + 8], 7, 1770035416); d = FF(d, a, b, c, m[i + 9], 12, -1958414417); c = FF(c, d, a, b, m[i + 10], 17, -42063); b = FF(b, c, d, a, m[i + 11], 22, -1990404162); a = FF(a, b, c, d, m[i + 12], 7, 1804603682); d = FF(d, a, b, c, m[i + 13], 12, -40341101); c = FF(c, d, a, b, m[i + 14], 17, -1502002290); b = FF(b, c, d, a, m[i + 15], 22, 1236535329); a = GG(a, b, c, d, m[i + 1], 5, -165796510); d = GG(d, a, b, c, m[i + 6], 9, -1069501632); c = GG(c, d, a, b, m[i + 11], 14, 643717713); b = GG(b, c, d, a, m[i + 0], 20, -373897302); a = GG(a, b, c, d, m[i + 5], 5, -701558691); d = GG(d, a, b, c, m[i + 10], 9, 38016083); c = GG(c, d, a, b, m[i + 15], 14, -660478335); b = GG(b, c, d, a, m[i + 4], 20, -405537848); a = GG(a, b, c, d, m[i + 9], 5, 568446438); d = GG(d, a, b, c, m[i + 14], 9, -1019803690); c = GG(c, d, a, b, m[i + 3], 14, -187363961); b = GG(b, c, d, a, m[i + 8], 20, 1163531501); a = GG(a, b, c, d, m[i + 13], 5, -1444681467); d = GG(d, a, b, c, m[i + 2], 9, -51403784); c = GG(c, d, a, b, m[i + 7], 14, 1735328473); b = GG(b, c, d, a, m[i + 12], 20, -1926607734); a = HH(a, b, c, d, m[i + 5], 4, -378558); d = HH(d, a, b, c, m[i + 8], 11, -2022574463); c = HH(c, d, a, b, m[i + 11], 16, 1839030562); b = HH(b, c, d, a, m[i + 14], 23, -35309556); a = HH(a, b, c, d, m[i + 1], 4, -1530992060); d = HH(d, a, b, c, m[i + 4], 11, 1272893353); c = HH(c, d, a, b, m[i + 7], 16, -155497632); b = HH(b, c, d, a, m[i + 10], 23, -1094730640); a = HH(a, b, c, d, m[i + 13], 4, 681279174); d = HH(d, a, b, c, m[i + 0], 11, -358537222); c = HH(c, d, a, b, m[i + 3], 16, -722521979); b = HH(b, c, d, a, m[i + 6], 23, 76029189); a = HH(a, b, c, d, m[i + 9], 4, -640364487); d = HH(d, a, b, c, m[i + 12], 11, -421815835); c = HH(c, d, a, b, m[i + 15], 16, 530742520); b = HH(b, c, d, a, m[i + 2], 23, -995338651); a = II(a, b, c, d, m[i + 0], 6, -198630844); d = II(d, a, b, c, m[i + 7], 10, 1126891415); c = II(c, d, a, b, m[i + 14], 15, -1416354905); b = II(b, c, d, a, m[i + 5], 21, -57434055); a = II(a, b, c, d, m[i + 12], 6, 1700485571); d = II(d, a, b, c, m[i + 3], 10, -1894986606); c = II(c, d, a, b, m[i + 10], 15, -1051523); b = II(b, c, d, a, m[i + 1], 21, -2054922799); a = II(a, b, c, d, m[i + 8], 6, 1873313359); d = II(d, a, b, c, m[i + 15], 10, -30611744); c = II(c, d, a, b, m[i + 6], 15, -1560198380); b = II(b, c, d, a, m[i + 13], 21, 1309151649); a = II(a, b, c, d, m[i + 4], 6, -145523070); d = II(d, a, b, c, m[i + 11], 10, -1120210379); c = II(c, d, a, b, m[i + 2], 15, 718787259); b = II(b, c, d, a, m[i + 9], 21, -343485551); a = a + aa >>> 0; b = b + bb >>> 0; c = c + cc >>> 0; d = d + dd >>> 0; } return crypt.endian([a, b, c, d]); }; md52._ff = function(a, b, c, d, x, s, t) { var n = a + (b & c | ~b & d) + (x >>> 0) + t; return (n << s | n >>> 32 - s) + b; }; md52._gg = function(a, b, c, d, x, s, t) { var n = a + (b & d | c & ~d) + (x >>> 0) + t; return (n << s | n >>> 32 - s) + b; }; md52._hh = function(a, b, c, d, x, s, t) { var n = a + (b ^ c ^ d) + (x >>> 0) + t; return (n << s | n >>> 32 - s) + b; }; md52._ii = function(a, b, c, d, x, s, t) { var n = a + (c ^ (b | ~d)) + (x >>> 0) + t; return (n << s | n >>> 32 - s) + b; }; md52._blocksize = 16; md52._digestsize = 16; module.exports = function(message, options) { if (message === void 0 || message === null) throw new Error("Illegal argument " + message); var digestbytes = crypt.wordsToBytes(md52(message, options)); return options && options.asBytes ? digestbytes : options && options.asString ? bin.bytesToString(digestbytes) : crypt.bytesToHex(digestbytes); }; })(); } }); // 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) { const values = []; const iArguments = []; let loading2 = false; let loaded = false; function modify() { 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); } } 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(() => modify()); } else { modify(); } }); } return function() { modifyArguments?.(arguments); iArguments.push(arguments); }; } }); } function propertyHook(target, propertyKey, propertyValue) { Reflect.defineProperty(target, propertyKey, { configurable: true, set: (v) => true, get: () => { Reflect.defineProperty(target, propertyKey, { configurable: true, value: propertyValue }); return propertyValue; } }); } propertyHook.modify = (target, propertyKey, callback, once = false) => { 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; } }); }; 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-\${"e6541bd"}\`) || customElements.define(\`button-\${"e6541bd"}\`, PushButton); // src/html/popupbox.html var popupbox_default = '
\\r\\n
\\r\\n
\\r\\n
\\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-\${"e6541bd"}\`) || customElements.define(\`popupbox-\${"e6541bd"}\`, 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"}
\${msg}
\`; 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-\${"e6541bd"}\`) || customElements.define(\`toast-\${"e6541bd"}\`, 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-\${"e6541bd"}\`) || customElements.define(\`toast-container-\${"e6541bd"}\`, 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-e6541bd") || customElements.define("bilibili-entry-e6541bd", 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 }; // 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) { 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(\` s = d, void 0)}\`)) { this.textContent(); this.html = this.html.replace(new RegExp(\`^ 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 }); Reflect.deleteProperty(window, "webpackJsonp"); } updateDom() { const title = document.title; this.vdom.replace(document.documentElement); Reflect.deleteProperty(window, "PlayerAgent"); 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