Skip to content

Commit

Permalink
Additional fixes for downloads
Browse files Browse the repository at this point in the history
  • Loading branch information
kmbarr committed Jun 12, 2022
1 parent ad4e9e5 commit 7852448
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/ts/QuerySelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

export enum QuerySelectors {
// Post
postWrapper = '.M9sTE, .NI8nC, article._aalr, article._aa6a, article._aatb, article._ab0-',
postWrapper = '.M9sTE, .NI8nC, article._aalr, article._aa6a, article._aatb, article._ab0-, article._ab6k',
postBookmark = '.wmtNn, ._aamz > div',
postSliderBubble = '.JSZAJ, .ijCUd, ._acnb',
postAccountName = "._aacl > ._aap6 >.oajrlxb2",
Expand All @@ -22,6 +22,7 @@ export enum QuerySelectors {
// Story
storyImage = '.y-yJ5, img._aa63',
storyCloseButton = '.K_10X, ._g3zU, .aUIsh, ._ac0g>._abl-',
storyAccountName = '._a3gq ._ac0q a',

// Account, Hover, Explore, Reels
accountImage = '._aarf._aarg ._aa8j, ._aa_j ._aarf ._aa8h ._aa8j',
Expand Down
3 changes: 2 additions & 1 deletion src/ts/downloaders/PostDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ export class PostDownloader extends Downloader {
}

private static async downloadWithOutSlider(element: HTMLElement): Promise<void> {
const postContentWrapper = document.querySelector(QuerySelectors.postContentWrapper);
const postContentWrapper = element.querySelector(QuerySelectors.postContentWrapper)
|| document.querySelector(QuerySelectors.postContentWrapper);
const img = postContentWrapper?.querySelector?.('img');
const video = postContentWrapper?.querySelector?.('video');

Expand Down
4 changes: 3 additions & 1 deletion src/ts/downloaders/StoryDownloader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,11 @@ export class StoryDownloader extends Downloader {
url = extractSrcSet(img);
}

const storyAccountName = (document.querySelector(QuerySelectors.storyAccountName) as HTMLElement | null)?.innerText || 'unknown';

const downloadMessage: DownloadMessage = {
imageURL: [url],
accountName: 'unknown',
accountName: storyAccountName,
type: DownloadType.single,
};
await browser.runtime.sendMessage(downloadMessage);
Expand Down

0 comments on commit 7852448

Please sign in to comment.