Skip to content

Commit

Permalink
Merge pull request #180 from SensCritique/release/1.5.2
Browse files Browse the repository at this point in the history
Release 1.5.2 : Correction de la loop infini (le retour) sur PrimeVideo
  • Loading branch information
audreylamy authored May 15, 2024
2 parents bab068a + 4d2165f commit 2f77db6
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 12 deletions.
2 changes: 1 addition & 1 deletion manifest_chrome.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "SensCritique",
"version": "1.5.1",
"version": "1.5.2",
"description": "Vous avez du mal à trouver des bons programmes sur vos plateformes de streaming ?",
"icons": {
"48": "images/logo-48.png",
Expand Down
2 changes: 1 addition & 1 deletion manifest_firefox.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "SensCritique",
"version": "1.5.1",
"version": "1.5.2",
"description": "La note SensCritique est une boussole pour arrêter de perdre votre temps, et s’invite sur Netflix, Prime Video et Disney+ pour vous permettre de choisir de manière éclairée vos programmes.",
"icons": {
"48": "images/logo-48.png",
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "senscritique-extension",
"version": "1.5.1",
"version": "1.5.2",
"description": "La note SensCritique est une boussole pour arrêter de perdre votre temps, et s’invite sur Netflix, Prime Video et Disney+ pour vous permettre de choisir de manière éclairée vos programmes.",
"author": "SensCritique",
"repository": {
Expand Down
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
22 changes: 18 additions & 4 deletions src/dom/providers/PrimeVideo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,22 @@ export default class PrimeVideo extends Manager {

renderWallRatings(browserExtensionProducts: BrowserExtensionProduct[]): void {
// Response from API with all browserExtensionProducts
browserExtensionProducts.forEach((browserExtensionProduct) => {
browserExtensionProducts.forEach(async (browserExtensionProduct) => {
// Note : Save in cache product information before rendering to prevent UI bugs
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 wallElements = document.querySelectorAll(
`[data-testid="packshot"] a[href*="/detail/${platformId}"][role="button"]:not([class*="tst-"])`
Expand All @@ -105,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 @@ -121,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 @@ -148,7 +162,7 @@ export default class PrimeVideo extends Manager {
})
}
}
})
}
})
}

Expand Down

0 comments on commit 2f77db6

Please sign in to comment.