Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from MotooriKashin:master #257

Merged
merged 2 commits into from
Sep 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 58 additions & 1 deletion src/core/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -106,6 +106,58 @@ export class Comment {
}
});
}

protected BiliComments() {
Reflect.defineProperty(self, 'BiliComments', {
configurable: true,
set: v => true,
get: () => {
return class extends EventTarget {

$parent?: HTMLElement;

constructor(private arg: IBiliComments) {
super();
}

mount(parent: HTMLElement) {
if (load) {
this.$parent = parent;
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;
}

dispatchAction({ type, args, callback }: any) {
switch (type) {
case 'reload': {
const [type, oid] = args[0].params.split(",");
this.$parent?.replaceChildren();
new Feedback(this.$parent, oid, type, undefined, this.arg.seekId);
callback?.();
break;
}
}
}
}
}
});
}

/** 修复按时间排序评论翻页数 */
protected pageCount() {
jsonpHook("api.bilibili.com/x/v2/reply?", undefined, (res, url) => {
Expand Down Expand Up @@ -573,3 +625,8 @@ export class Comment {
}
}
}

interface IBiliComments {
params: string;
seekId?: number;
}
53 changes: 50 additions & 3 deletions tampermonkey/comment/main.user.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tampermonkey/comment/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Bilibili 翻页评论区",
"namespace": "MotooriKashin",
"version": "2.2.7",
"version": "2.2.9",
"description": "恢复评论区翻页功能。",
"author": "MotooriKashin",
"homepage": "https://github.com/MotooriKashin/Bilibili-Old",
Expand Down
51 changes: 49 additions & 2 deletions tampermonkey/main.user.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tampermonkey/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Bilibili 旧播放页",
"namespace": "MotooriKashin",
"version": "10.8.3",
"version": "10.8.5",
"description": "恢复Bilibili旧版页面,为了那些念旧的人。",
"author": "MotooriKashin, wly5556",
"homepage": "https://github.com/MotooriKashin/Bilibili-Old",
Expand Down
Loading