Skip to content
This repository has been archived by the owner on Dec 30, 2024. It is now read-only.

Commit

Permalink
Modified TPs invalid post check logic
Browse files Browse the repository at this point in the history
  • Loading branch information
WombatFromHell committed Nov 18, 2020
1 parent f8d80fd commit 4b4c1b5
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/optional/threadpane/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export const clonePostBody = (postElem: HTMLElement) => {
export const parseRoot = (rootElem: HTMLElement, user: string) => {
const root = elemMatches(rootElem, "div.root");
const rootid = root && parseInt(root?.id?.substr(5));
// try to return early for threads with invalid ids
if (rootid < 1 || rootid > 50000000) {
console.error(`The thread ID of ${rootid} seems bogus.`);
return null;
Expand All @@ -158,12 +159,13 @@ export const parseRoot = (rootElem: HTMLElement, user: string) => {
const authorid = parseInt(fullpost.getAttribute("class")?.split("fpauthor_")?.[1]);
const author = getAuthor(rootLi);
const body = clonePostBody(root?.querySelector("div.postbody") as HTMLElement);
if (!author || !body) {
console.error(`Encountered what looks like a nuked post:`, rootid, root);
const count = [...rootLi?.querySelectorAll("div.capcontainer li")]?.length;
// return blank cards for potentially invalid root posts
if ((!author && !body) || !author || (!body && count === 0)) {
console.error(`Encountered what looks like a nuked or invalid post:`, rootid, root);
return null;
}
const mod = getMod(fullpost);
const count = [...rootLi?.querySelectorAll("div.capcontainer li")]?.length;
const recents = getRecents(root);
const contained = threadContainsLoggedUser(rootElem, user);
const collapsed = !!Collapse.findCollapsed(rootid);
Expand Down

0 comments on commit 4b4c1b5

Please sign in to comment.