Skip to content

Commit

Permalink
page redesign (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrbusche authored Nov 20, 2024
1 parent 20ddbef commit 96c3732
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
javascript: (function () {
function removeItemsWithoutPriceDrops() {
const lowPrice = 999999;
let anyRemoved = false;
const listItems = document.getElementsByClassName('a-spacing-none g-item-sortable');
const listItems = document.getElementsByClassName("a-list-item");
const listItemsArray = Array.from(listItems);

for (const element of listItems) {
let priceDrop = element.querySelectorAll('span div div div div div div div div div div div.a-row.itemPriceDrop').length;
let coupon = element.querySelectorAll('span div div div div div div div div div div div i[id^="coupon-badge"]').length;
let dealBadge = element.querySelectorAll('span div div div div div div div div div div span.wl-deal-rich-badge').length;
let price = (priceDrop || coupon || dealBadge) ? element.querySelectorAll('span.a-offscreen')[0].innerText.replace('$', '') : 0;
if (!(priceDrop || coupon || dealBadge) || price > lowPrice) {
element.parentElement.removeChild(element);
anyRemoved = true;
}
}
for (const element of listItemsArray) {
const item = element.querySelector('[id^="itemMain"]');

if (anyRemoved) {
removeItemsWithoutPriceDrops();
if (item) {
const hasPriceDrop = item.querySelector(".itemPriceDrop") !== null;
const hasCoupon = item.querySelector('[id^="coupon-badge"]') !== null;
const hasDealBadge = item.querySelector(".wl-deal-rich-badge") !== null;

if (hasPriceDrop || hasCoupon || hasDealBadge) {
const priceText = element.querySelector("span.a-offscreen").innerText;
const price = parseFloat(priceText.replace("$", ""));
if (price > lowPrice) {
element.parentElement.removeChild(element);
}
} else {
element.parentElement.removeChild(element);
}
}
}
}

Expand Down

0 comments on commit 96c3732

Please sign in to comment.