Skip to content

Commit

Permalink
fix for amazon's recent markup changes on seller page
Browse files Browse the repository at this point in the history
  • Loading branch information
tadwohlrapp committed Feb 24, 2023
1 parent cd29c0a commit fa0bd1d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions userscript/soldby.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -419,15 +419,16 @@
const isRedesign = sellerProfileContainer.classList.contains('spp-redesigned');

const country = getSellerCountryFromSellerPage(sellerPage, isRedesign); // returns DE
const rating = getSellerRatingFromSellerPage(sellerPage, isRedesign); // returns 91%
const rating = getSellerRatingFromSellerPage(sellerPage); // returns 91%

return { country, rating };
}

function getSellerCountryFromSellerPage(sellerPage, isRedesign) {
let country;
if (isRedesign) {
country = sellerPage.querySelector('#page-section-detail-seller-info .a-box-inner .a-row:last-of-type span')?.textContent.toUpperCase();
let addressArr = sellerPage.querySelectorAll('#page-section-detail-seller-info .a-box-inner .a-row.a-spacing-none.indent-left');
country = addressArr[addressArr.length - 1]?.textContent.toUpperCase();
} else {
try {
const sellerUl = sellerPage.querySelectorAll('ul.a-unordered-list.a-nostyle.a-vertical'); //get all ul
Expand All @@ -442,13 +443,12 @@
return (/^[A-Z]{2}$/.test(country)) ? country : '?';
}

function getSellerRatingFromSellerPage(sellerPage, isRedesign) {
let idSuffix = isRedesign ? '-rd' : '';
if (sellerPage.getElementById('sellerName' + idSuffix).textContent.includes('Amazon')) {
function getSellerRatingFromSellerPage(sellerPage) {
if (sellerPage.getElementById('seller-name').textContent.includes('Amazon')) {
return false; // seller is Amazon subsidiary and doesn't display ratings
}

let text = sellerPage.getElementById('seller-feedback-summary' + idSuffix).textContent;
let text = sellerPage.getElementById('seller-info-feedback-summary').textContent;
let regex = /(\d+%).*?\((\d+)/;
let zeroPercent = '0%';

Expand Down

0 comments on commit fa0bd1d

Please sign in to comment.