Skip to content

Commit

Permalink
fix: facebook photos page scroll
Browse files Browse the repository at this point in the history
We now track the first photo clicked, and stop once that one is found
again
  • Loading branch information
Chickensoupwithrice committed Sep 14, 2023
1 parent de518a8 commit 9ebc18d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/site/facebook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Q = {
commentMoreComments: "./following-sibling::div/div/div[2][@role='button'][./span/span]",
viewComments: ".//h4/..//div[@role='button']",
photoCommentList: "//ul[../h2]",
firstPhotoThumbnail: "//div[@role='main']//div[3]//div[contains(@style, 'border-radius')]//div[contains(@style, 'max-width') and contains(@style, 'min-width')]//a[@role='link']",
firstPhotoThumbnail: "//*[@id=\"mount_0_0_4m\"]/div/div[1]/div/div[3]/div/div/div/div[1]/div[1]/div/div/div[4]/div/div/div/div/div/div/div/div/div[3]/div[1]/div[1]/div/div/a",
firstVideoThumbnail: "//div[@role='main']//div[contains(@style, 'z-index')]/following-sibling::div/div/div/div[last()]//a[contains(@href, '/videos/') and @aria-hidden!='true']",
firstVideoSimple: "//div[@role='main']//a[contains(@href, '/videos/') and @aria-hidden!='true']",
mainVideo: "//div[@data-pagelet='root']//div[@role='dialog']//div[@role='main']//video",
Expand Down Expand Up @@ -275,6 +275,7 @@ export class FacebookTimelineBehavior {
firstPhoto.click();
await sleep(waitUnit * 5);
await waitUntil(() => window.location.href !== lastHref, waitUnit * 2);
const firstPhotoHref = window.location.href;

let nextSlideButton = null;

Expand All @@ -290,7 +291,8 @@ export class FacebookTimelineBehavior {
sleep(3000)
]);

if (window.location.href === lastHref) {
// Exit once we've looped
if (window.location.href === firstPhotoHref) {
break;
}

Expand Down

0 comments on commit 9ebc18d

Please sign in to comment.