diff --git a/src/core/comment.ts b/src/core/comment.ts index 853052be..e9457ffa 100644 --- a/src/core/comment.ts +++ b/src/core/comment.ts @@ -28,12 +28,12 @@ export class Comment { events = {}; this.bbComment(); this.initComment(); + this.BiliComments(); this.pageCount(); this.jump(); } /** 捕获评论组件 */ protected bbComment() { - const that = this; Reflect.defineProperty(window, "bbComment", { configurable: true, set: v => { @@ -106,6 +106,42 @@ export class Comment { } }); } + + protected BiliComments() { + Reflect.defineProperty(self, 'BiliComments', { + configurable: true, + set: v => true, + get: () => { + return class extends EventTarget { + constructor(private arg: IBiliComments) { + super(); + } + + mount(parent: HTMLElement) { + if (load) { + const [type, oid] = this.arg.params.split(","); + new Feedback(parent, oid, type, undefined, this.arg.seekId); + setTimeout(() => { + this.dispatchEvent(new Event('inited')); + this.dispatchEvent(new Event('expand')); + // this.dispatchEvent(new Event('seek')); + }); + } else { + if (!loading) { + loadScript(`//s1.hdslb.com/bfs/seed/jinkela/commentpc/comment.min.js`).then(() => { + load = true; + }) + } + loading = true; + setTimeout(() => this.mount(parent), 100); + } + return this; + } + } + } + }); + } + /** 修复按时间排序评论翻页数 */ protected pageCount() { jsonpHook("api.bilibili.com/x/v2/reply?", undefined, (res, url) => { @@ -573,3 +609,8 @@ export class Comment { } } } + +interface IBiliComments { + params: string; + seekId?: number; +} \ No newline at end of file diff --git a/tampermonkey/comment/main.user.js b/tampermonkey/comment/main.user.js index 595a9953..4c9f1b2a 100644 --- a/tampermonkey/comment/main.user.js +++ b/tampermonkey/comment/main.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Bilibili 翻页评论区 // @namespace MotooriKashin -// @version 2.2.7 +// @version 2.2.8 // @description 恢复评论区翻页功能。 // @author MotooriKashin // @homepage https://github.com/MotooriKashin/Bilibili-Old @@ -839,7 +839,7 @@ var PreviewImage = class extends HTMLElement { document.body.style.overflow = "hidden"; } }; -customElements.get(`preview-image-${"81g6kk2st1y"}`) || customElements.define(`preview-image-${"81g6kk2st1y"}`, PreviewImage); +customElements.get(`preview-image-${"v95uvd9kmh"}`) || customElements.define(`preview-image-${"v95uvd9kmh"}`, PreviewImage); // src/core/comment.ts var Feedback; @@ -860,12 +860,12 @@ var Comment = class _Comment { events = {}; this.bbComment(); this.initComment(); + this.BiliComments(); this.pageCount(); this.jump(); } /** 捕获评论组件 */ bbComment() { - const that = this; Reflect.defineProperty(window, "bbComment", { configurable: true, set: (v) => { @@ -937,6 +937,39 @@ var Comment = class _Comment { } }); } + BiliComments() { + Reflect.defineProperty(self, "BiliComments", { + configurable: true, + set: (v) => true, + get: () => { + return class extends EventTarget { + constructor(arg) { + super(); + this.arg = arg; + } + mount(parent) { + if (load) { + const [type, oid] = this.arg.params.split(","); + new Feedback(parent, oid, type, void 0, this.arg.seekId); + setTimeout(() => { + this.dispatchEvent(new Event("inited")); + this.dispatchEvent(new Event("expand")); + }); + } else { + if (!loading) { + loadScript(`//s1.hdslb.com/bfs/seed/jinkela/commentpc/comment.min.js`).then(() => { + load = true; + }); + } + loading = true; + setTimeout(() => this.mount(parent), 100); + } + return this; + } + }; + } + }); + } /** 修复按时间排序评论翻页数 */ pageCount() { jsonpHook("api.bilibili.com/x/v2/reply?", void 0, (res, url) => { diff --git a/tampermonkey/comment/manifest.json b/tampermonkey/comment/manifest.json index fd115700..f0717ac3 100644 --- a/tampermonkey/comment/manifest.json +++ b/tampermonkey/comment/manifest.json @@ -1,7 +1,7 @@ { "name": "Bilibili 翻页评论区", "namespace": "MotooriKashin", - "version": "2.2.7", + "version": "2.2.8", "description": "恢复评论区翻页功能。", "author": "MotooriKashin", "homepage": "https://github.com/MotooriKashin/Bilibili-Old", diff --git a/tampermonkey/main.user.js b/tampermonkey/main.user.js index e8315751..d94dda40 100644 --- a/tampermonkey/main.user.js +++ b/tampermonkey/main.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Bilibili 旧播放页 // @namespace MotooriKashin -// @version 10.8.3-1272ee50230293555dec1d2e23fc5c74215b4c86 +// @version 10.8.4-1272ee50230293555dec1d2e23fc5c74215b4c86 // @description 恢复Bilibili旧版页面,为了那些念旧的人。 // @author MotooriKashin, wly5556 // @homepage https://github.com/MotooriKashin/Bilibili-Old @@ -28837,12 +28837,12 @@ const MODULES = ` events = {}; this.bbComment(); this.initComment(); + this.BiliComments(); this.pageCount(); this.jump(); } /** 捕获评论组件 */ bbComment() { - const that = this; Reflect.defineProperty(window, "bbComment", { configurable: true, set: (v) => { @@ -28914,6 +28914,39 @@ const MODULES = ` } }); } + BiliComments() { + Reflect.defineProperty(self, "BiliComments", { + configurable: true, + set: (v) => true, + get: () => { + return class extends EventTarget { + constructor(arg) { + super(); + this.arg = arg; + } + mount(parent) { + if (load) { + const [type, oid] = this.arg.params.split(","); + new Feedback(parent, oid, type, void 0, this.arg.seekId); + setTimeout(() => { + this.dispatchEvent(new Event("inited")); + this.dispatchEvent(new Event("expand")); + }); + } else { + if (!loading) { + loadScript(\`//s1.hdslb.com/bfs/seed/jinkela/commentpc/comment.min.js\`).then(() => { + load = true; + }); + } + loading = true; + setTimeout(() => this.mount(parent), 100); + } + return this; + } + }; + } + }); + } /** 修复按时间排序评论翻页数 */ pageCount() { jsonpHook("api.bilibili.com/x/v2/reply?", void 0, (res, url) => { diff --git a/tampermonkey/manifest.json b/tampermonkey/manifest.json index c4aa2ec3..e13f2f95 100644 --- a/tampermonkey/manifest.json +++ b/tampermonkey/manifest.json @@ -1,7 +1,7 @@ { "name": "Bilibili 旧播放页", "namespace": "MotooriKashin", - "version": "10.8.3", + "version": "10.8.4", "description": "恢复Bilibili旧版页面,为了那些念旧的人。", "author": "MotooriKashin, wly5556", "homepage": "https://github.com/MotooriKashin/Bilibili-Old",