From 4a25b03b6ca211bd4ef39ee1507a8767ad675649 Mon Sep 17 00:00:00 2001 From: josc146 Date: Mon, 4 Mar 2024 23:46:54 +0800 Subject: [PATCH] update adaption for reddit (#416) --- src/content-script/site-adapters/index.mjs | 4 ++-- src/content-script/site-adapters/reddit/index.mjs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/content-script/site-adapters/index.mjs b/src/content-script/site-adapters/index.mjs index 12acdbbf..15801d0d 100644 --- a/src/content-script/site-adapters/index.mjs +++ b/src/content-script/site-adapters/index.mjs @@ -170,9 +170,9 @@ export const config = { }, reddit: { inputQuery: reddit.inputQuery, - sidebarContainerQuery: ['#pdp-right-rail-topics div'], + sidebarContainerQuery: ['aside > div'], appendContainerQuery: [], - resultsContainerQuery: ['#pdp-right-rail-topics div'], + resultsContainerQuery: ['aside > div'], }, quora: { inputQuery: quora.inputQuery, diff --git a/src/content-script/site-adapters/reddit/index.mjs b/src/content-script/site-adapters/reddit/index.mjs index 76a65b15..f1dcb249 100644 --- a/src/content-script/site-adapters/reddit/index.mjs +++ b/src/content-script/site-adapters/reddit/index.mjs @@ -3,11 +3,11 @@ import { cropText } from '../../../utils' export default { inputQuery: async () => { try { - const title = document.querySelector('.main shreddit-post div:nth-child(4)').textContent + const title = document.querySelector('[id*="post-title"]').textContent const description = document.querySelector( - '.main shreddit-post div:nth-child(6) div', + 'shreddit-post > div.text-neutral-content', ).textContent - const texts = document.querySelectorAll('shreddit-comment div:nth-child(2)') + const texts = document.querySelectorAll('shreddit-comment div.md') let answers = '' for (let i = 0; i < texts.length; i++) { answers += `answer${i}:${texts[i].textContent}|`