feat: improved purchase button detection

for the hundredth time
This commit is contained in:
Index 2024-07-17 17:10:46 -05:00
parent 9c8a08cf78
commit c6a3ce2c69

View file

@ -1,6 +1,5 @@
const ItemID = window.location.pathname.split('/')[2]; const ItemID = window.location.pathname.split('/')[2];
const ItemType = document.querySelector('.row .badge').innerHTML; const ItemType = document.querySelector('.row .badge').innerHTML;
console.log(ItemType);
var Settings; var Settings;
var ItemWishlist; var ItemWishlist;
@ -19,11 +18,8 @@ var Utilities;
chrome.storage.sync.get(['PolyPlus_Settings'], async function (result) { chrome.storage.sync.get(['PolyPlus_Settings'], async function (result) {
Settings = result.PolyPlus_Settings || {}; Settings = result.PolyPlus_Settings || {};
PurchaseBtn = document.querySelector('.btn[onclick^="buy"]'); PurchaseBtn = document.querySelector('.col:has(h1) .justify-content-lg-end .d-flex .flex-grow-1:nth-child(2) :nth-child(1)')
if (PurchaseBtn === null) { ItemOwned = PurchaseBtn.innerText === ' Item owned' || PurchaseBtn.innerText === ' You earned this achievement' || document.querySelector('.btn[onclick="sellItem()"]') !== null;
PurchaseBtn = document.querySelector('.btn#purchase-button');
}
ItemOwned = PurchaseBtn.innerText === ' Item owned' || document.querySelector('.btn[onclick="sellItem()"]') !== null;
if (PurchaseBtn.getAttribute('data-seller-name')) { if (PurchaseBtn.getAttribute('data-seller-name')) {
PurchaseBtn.setAttribute('data-bs-toggle', 'tooltip'); PurchaseBtn.setAttribute('data-bs-toggle', 'tooltip');