Skip to content

Commit

Permalink
fix:
Browse files Browse the repository at this point in the history
* PrimeVideo/Netflix : coding style
* Netflix: Cache product info before rendering
  • Loading branch information
bt0r committed May 15, 2024
1 parent 2939d9b commit 4d2165f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
Binary file modified releases/latest_chrome.zip
Binary file not shown.
Binary file modified releases/latest_firefox.xpi
Binary file not shown.
20 changes: 16 additions & 4 deletions src/dom/providers/Netflix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,26 @@ export default class Netflix extends Manager {
browserExtensionProducts: BrowserExtensionProduct[]
): Promise<void> {
// Response from API with all browserExtensionProducts
browserExtensionProducts.forEach((browserExtensionProduct) => {
for (const browserExtensionProduct of browserExtensionProducts) {
const hash = md5(browserExtensionProduct.platformId.toString())
const videoInfo = {
name: name,
redirect: await generateRedirectUrl(name),
id: '',
url: browserExtensionProduct.url,
type: browserExtensionProduct.type,
rating: browserExtensionProduct?.rating?.toString(),
hash,
platformId: browserExtensionProduct?.platformId,
}

this.cache.save(videoInfo)
const platformId = browserExtensionProduct.platformId
const cardElements = document.querySelectorAll(
`.title-card a[href*="/watch/${platformId}"]`
)

cardElements.forEach(async (cardElement) => {
for (const cardElement of cardElements) {
const videoName = cardElement?.getAttribute('aria-label')
const hashClass = 'senscritique_' + hash
if (!cardElement.querySelector(`.${hashClass}`)) {
Expand All @@ -91,8 +103,8 @@ export default class Netflix extends Manager {
platformId: browserExtensionProduct?.platformId,
})
}
})
})
}
}
}

refreshModalRating(): void {
Expand Down
6 changes: 3 additions & 3 deletions src/dom/providers/PrimeVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export default class PrimeVideo extends Manager {
...legacyElements,
]

cardElements.forEach(async (cardElement: HTMLElement) => {
for (const cardElement of cardElements) {
// Only keep carousel and wall elements (without episode URL)
if (
cardElement.getAttribute('href')?.match(`/detail/${platformId}.*`) ||
Expand All @@ -135,7 +135,7 @@ export default class PrimeVideo extends Manager {
) {
const hashClass = 'senscritique_' + hash
if (!cardElement.querySelector(`.${hashClass}`)) {
let name = cardElement.innerText
let name = (cardElement as HTMLElement).innerText
const mainDiv = document.createElement('div')
mainDiv.style.position = 'absolute'
mainDiv.style.zIndex = '2'
Expand All @@ -162,7 +162,7 @@ export default class PrimeVideo extends Manager {
})
}
}
})
}
})
}

Expand Down

0 comments on commit 4d2165f

Please sign in to comment.