Skip to content

Commit

Permalink
feat: improve correctness on Amazon
Browse files Browse the repository at this point in the history
  • Loading branch information
mondaychen committed Mar 19, 2024
1 parent b814b62 commit c003248
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
22 changes: 22 additions & 0 deletions src/helpers/knowledge/db.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,27 @@
}
}
]
},
"amazon.com": {
"rules": [
{
"regexes": [".*"],
"knowledge": {
"notes": [
"Be careful not to confuse the \"Add to Cart\" with the \"Buy Now\". The \"Add to Cart\" button adds the item to the cart, while the \"Buy Now\" button takes you to the checkout page.",
"Do not confuse \"Buy Now\" and \"Buy New\" on product page.",
"You should always verify if the product is in stock before buying or adding to the cart. If the product is not in stock, you should notify the user about it."
]
}
},
{
"regexes": ["^/s$"],
"knowledge": {
"notes": [
"There is no \"Add to Cart\" button on the search results page. You need to click on the product name to go to the product details page first."
]
}
}
]
}
}
3 changes: 2 additions & 1 deletion src/helpers/knowledge/redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"twitter.com": "x.com",
"www.twitter.com": "x.com",
"www.x.com": "x.com",
"www.airbnb.com": "airbnb.com"
"www.airbnb.com": "airbnb.com",
"www.amazon.com": "amazon.com"
}
4 changes: 2 additions & 2 deletions src/pages/content/drawLabels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ function isVisible(
const { display, visibility, opacity } = style;
if (display === "none") return false;
if (visibility !== "visible") return false;
if (opacity != null && parseFloat(opacity) < 0.1) return false; // considering something very close to 0 as invisible
// don't respect 'aria-hidden' attribute since they are most likely visible to the user
if (opacity != null && parseFloat(opacity) <= 0) return false;
// don't respect 'aria-hidden' attribute since they are most likely visible in the screenshot
// if (element.getAttribute('aria-hidden') === 'true') return false;

const rect = element.getBoundingClientRect();
Expand Down
2 changes: 1 addition & 1 deletion src/pages/content/style.global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
animation: web-agent-ripple 0.5s ease-out;
background-color: rgba(0, 0, 255, 0.961);
pointer-events: none;
z-index: 9999;
z-index: 999999;
}

@keyframes web-agent-ripple {
Expand Down

0 comments on commit c003248

Please sign in to comment.