24 lines
1005 B
JavaScript
24 lines
1005 B
JavaScript
(function waitForBookWrappers(imageUrl) {
|
|
const interval = setInterval(() => {
|
|
const bookWrappers = document.querySelectorAll(".book-wrapper");
|
|
if (bookWrappers.length === 0) return;
|
|
|
|
bookWrappers.forEach(wrapper => {
|
|
const coverLink = wrapper.querySelector(".sp__the-cover a");
|
|
if (!coverLink || wrapper.querySelector(".shop_link")) return;
|
|
|
|
const hrefParts = coverLink.getAttribute("href").split("/");
|
|
const isbn = hrefParts[1];
|
|
|
|
const shopLink = document.createElement("p");
|
|
shopLink.innerHTML = `<a class="shop_link" href="https://cdcshoppingcart.uchicago.edu/Cart2/ChicagoBook?ISBN=${isbn}&PRESS=wvp" target="_blank">
|
|
<img src="${imageUrl}" alt="Shop Link">
|
|
</a>`;
|
|
|
|
wrapper.appendChild(shopLink);
|
|
});
|
|
|
|
clearInterval(interval);
|
|
}, 100);
|
|
})(window.searchShopLinkImageUrl); // Pass URL dynamically
|