Skip to content

Commit

Permalink
bugfix: handle updated DOM for listing badges (#37)
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick Erichsen <patrick.a.erichsen@gmail.com>
  • Loading branch information
Patrick-Erichsen authored Dec 19, 2021
1 parent cf2bdc9 commit f6c87ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "Offie - Airbnb Wifi Reviews",
"description": "View Wifi and workspace info from the Airbnb search results page.",
"manifest_version": 3,
"version": "0.0.12",
"version": "0.0.13",
"icons": {
"16": "img/offie-logo-16.png",
"48": "img/offie-logo-48.png",
Expand Down
12 changes: 10 additions & 2 deletions src/content/utils/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,24 @@ export const insertBeforeBadge = (
listingDetails: HTMLElement,
offieNode: HTMLElement
): void => {
const badgeContainer = listingDetails.children[
const badgeParentContainer = listingDetails.children[
listingDetails.childElementCount - 2
] as HTMLElement;

if (!badgeContainer) {
if (!badgeParentContainer) {
throw new Error(
`Failed to find the 'badgeContainer' var in ${insertBeforeBadge.name}`
);
}

const badgeContainer = badgeParentContainer.children[0] as HTMLElement;

if (!badgeParentContainer) {
throw new Error(
`Failed to find the 'badgeParentContainer' var in ${insertBeforeBadge.name}`
);
}

/**
* Heuristic: `Rare find` badge has a diamond svg
*/
Expand Down

0 comments on commit f6c87ba

Please # to comment.