// ==UserScript== // @name 【哔哩哔哩】显示合集中的视频 // @version 0.1.1 // @description 已登录且以自己视角查看时,显示合集中的视频。 // @icon https://static.hdslb.com/images/favicon.ico // @match https://space.bilibili.com/* // @grant unsafeWindow // @run-at document-start // @namespace https://github.com/AkagiYui/UserScript // @supportURL https://github.com/AkagiYui/UserScript/issues // @homepage https://github.com/AkagiYui // @author AkagiYui // @license MIT // ==/UserScript== /******/ (() => { // webpackBootstrap /******/ "use strict"; /******/ var __webpack_modules__ = ({ /***/ 636: /***/ ((__unused_webpack_module, exports) => { Object.defineProperty(exports, "__esModule", ({ value: true })); exports.useBooleanMenu = exports.useLogger = void 0; /** * 生成 Logger * @param name 前缀 * @returns console.log */ const useLogger = (name) => { if (name) { return console.log.bind(console, "AkagiYui", `[${name}]`); } return console.log.bind(console, "AkagiYui"); }; exports.useLogger = useLogger; /** * 布尔菜单配置 * @param configs 配置项 * @returns 配置获取函数 */ const useBooleanMenu = (configs) => { // 缓存 const cache = {}; // 获取配置 const getConfig = (key) => { if (cache[key] !== undefined) { return cache[key]; } let value = GM_getValue(key, configs[key].defaultValue); cache[key] = value; return value; }; // 配置注册 let menuIds = []; const registerMenuCommand = () => { menuIds.forEach((id) => { GM_unregisterMenuCommand(id); }); menuIds = []; Object.entries(configs).forEach(([key, config]) => { let commandName = getConfig(key) ? "✅" : "❌"; commandName += ` ${config.title}`; let id = GM_registerMenuCommand(commandName, () => { let newValue = !getConfig(key); let valueToSet = config.callback ? config.callback(newValue) : newValue; GM_setValue(key, valueToSet); cache[key] = valueToSet; registerMenuCommand(); }); menuIds.push(id); }); }; registerMenuCommand(); return { getConfig }; }; exports.useBooleanMenu = useBooleanMenu; /***/ }) /******/ }); /************************************************************************/ /******/ // The module cache /******/ var __webpack_module_cache__ = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ // Check if module is in cache /******/ var cachedModule = __webpack_module_cache__[moduleId]; /******/ if (cachedModule !== undefined) { /******/ return cachedModule.exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = __webpack_module_cache__[moduleId] = { /******/ // no module.id needed /******/ // no module.loaded needed /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__); /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /************************************************************************/ var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk. (() => { var exports = __webpack_exports__; var __webpack_unused_export__; __webpack_unused_export__ = ({ value: true }); const utils_1 = __webpack_require__(636); const log = (0, utils_1.useLogger)("bilibili-show-videos-in-collection"); const pageWindow = unsafeWindow; const originalDefineProperty = pageWindow.Object.defineProperty; pageWindow.Object.defineProperty = function (target, propertyKey, descriptor) { if (propertyKey === "visibleVideoList") { log("定义 应显示视频列表", target, descriptor, descriptor.get, descriptor.set); const originGetter = descriptor.get.bind(target); return originalDefineProperty(target, propertyKey, { configurable: true, enumerable: true, get: function () { log("获取 应显示视频列表", this); // favListDetails: 收藏夹视频列表 // submitVideos: 投稿视频列表 return this.favListDetails?.medias ?? this.submitVideos?.vlist ?? originGetter(); }, set: () => { }, }); // 为确保在转到其他路由再次加载时仍然有效,此处不可恢复defineProperty。 } return originalDefineProperty(target, propertyKey, descriptor); }; })(); /******/ })() ;