Skip to content

Commit

Permalink
Merge pull request #69 from yakisova41/doesnt-work-web_20230815_01_RC01
Browse files Browse the repository at this point in the history
Doesnt work web 20230815 01 rc01
  • Loading branch information
yakisova41 authored Aug 22, 2023
2 parents 25d5c63 + 867f0f7 commit fcf20db
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/handlers/handleYtReloadContinuationItemsCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function handleYtReloadContinuationItemsCommand(
): void {
const reloadDetail: YtAction<YtReloadContinuationItemsCommandArg0, Element> =
detail;

const { slot } = reloadDetail.args[0].reloadContinuationItemsCommand;

if (slot === "RELOAD_CONTINUATION_SLOT_BODY") {
Expand Down
7 changes: 5 additions & 2 deletions src/rewrites/comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export function rewriteCommentNameFromContinuationItems(

if (commentThreadRenderer !== undefined) {
const { trackingParams } = commentThreadRenderer;

void getCommentElem(trackingParams).then((commentElem) => {
reWriteCommentElem(commentElem, commentThreadRenderer);
});
Expand All @@ -49,7 +48,11 @@ function reWriteCommentElem(
commentElem: ShadyElement,
commentThreadRenderer: ConfinuationItem
): void {
const commentRenderer = commentElem.__shady_native_children[0];
const commentRenderer = Array.from(
commentElem.__shady_native_children
).filter((elem) => {
return elem.id === "comment";
})[0];

if (commentRenderer !== null && commentRenderer !== undefined) {
let isContainer =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { type ShadyElement } from "../../utils/findElementByTrackingParams";
import { getUserName } from "../../utils/getUserName";
import { escapeString } from "../../utils/escapeString";
import { debugErr } from "src/utils/debugLog";

/**
Expand All @@ -10,8 +9,18 @@ import { debugErr } from "src/utils/debugLog";
export function mentionRewriteOfCommentRenderer(
commentRenderer: ShadyElement
): void {
const commentRendererBody = commentRenderer.__shady_native_children[2];
const main = commentRendererBody.__shady_native_children[1];
const commentRendererBody = Array.from(
commentRenderer.__shady_native_children
).filter((elem) => {
return elem.id === "body";
})[0];

const main = Array.from(commentRendererBody.__shady_native_children).filter(
(elem) => {
return elem.id === "main";
}
)[0];

const aTags = main.querySelectorAll(
"#comment-content > ytd-expander > #content > #content-text > a"
);
Expand All @@ -23,7 +32,7 @@ export function mentionRewriteOfCommentRenderer(
if (href !== null) {
void getUserName(href.split("/")[2])
.then((name) => {
aTag.textContent = `@${escapeString(name)} `;
aTag.textContent = `@${name} `;
})
.catch((e) => {
debugErr(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ export function nameRewriteOfCommentRenderer(
isNameContainerRender: boolean,
userId: string
): void {
const commentRendererBody = commentRenderer.__shady_native_children[2];
const commentRendererBody = Array.from(
commentRenderer.__shady_native_children
).filter((elem) => {
return elem.id === "body";
})[0];

let nameElem = commentRendererBody.querySelector<ShadyElement>(
"#main > #header > #header-author > h3 > a > span"
Expand All @@ -24,8 +28,11 @@ export function nameRewriteOfCommentRenderer(
* チャンネル所有者のコメントは別の要素に名前がかかれる
*/
if (isNameContainerRender) {
nameElem =
commentRendererBody.__shady_native_children[1].querySelector<ShadyElement>(
nameElem = Array.from(commentRendererBody.__shady_native_children)
.filter((elem) => {
return elem.id === "main";
})[0]
.querySelector<ShadyElement>(
"#header > #header-author > #author-comment-badge > ytd-author-comment-badge-renderer > a > #channel-name > #container > #text-container > yt-formatted-string"
);
}
Expand Down

0 comments on commit fcf20db

Please sign in to comment.