// ==UserScript==
// @name Daz - Restore Add to Cart + Cleanup
// @namespace http://tampermonkey.net/
// @version 1.4
// @description just fix
// @author DazUser
// @match https://www.daz3d.com/*
// @match https://daz3d.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=tampermonkey.net
// @run-at document-start
// @grant GM_addStyle
// ==/UserScript==
(function () {
'use strict';
GM_addStyle(`
ul.static_add_btns.cartable-item.tm-owned-fixed .add-to-wishlist,
ul.static_add_btns.cartable-item.tm-owned-fixed .wishlist-buttons,
ul.static_add_btns.cartable-item.tm-owned-fixed .rating-vote-container,
ul.static_add_btns.cartable-item.tm-owned-fixed .btn-product-owned,
ul.static_add_btns.cartable-item.tm-owned-fixed .btn-in-cart,
ul.static_add_btns.cartable-item.tm-owned-fixed .btn-license {
display: none !important;
}
ul.static_add_btns.cartable-item.tm-owned-fixed .btn-cart {
display: inline-block !important;
visibility: visible !important;
opacity: 1 !important;
}
`);
function fixAll() {
document.querySelectorAll('ul.static_add_btns.cartable-item').forEach(block => {
const ownedBtn = block.querySelector('.btn-product-owned.btn-purchased');
// If there is no button or it's hidden - undo the corrections and exit
if (!ownedBtn || ownedBtn.style.display === 'none') {
block.classList.remove('tm-owned-fixed');
return;
}
block.classList.add('tm-owned-fixed');
const cartBtn = block.querySelector('button[title="Add to Cart"], .btn-cart');
if (cartBtn) {
cartBtn.removeAttribute('hidden');
cartBtn.removeAttribute('disabled');
cartBtn.style.removeProperty('display');
cartBtn.style.setProperty('display', 'inline-block', 'important');
}
});
}
let lastUrl = location.href;
function startPolling() {
const timer = setInterval(() => {
if (location.href !== lastUrl) {
lastUrl = location.href;
setTimeout(fixAll, 1000);
setTimeout(fixAll, 2000);
setTimeout(fixAll, 3000);
}
fixAll();
}, 800);
}
window.addEventListener('load', () => {
fixAll();
setTimeout(fixAll, 1000);
setTimeout(fixAll, 2000);
startPolling();
});
document.addEventListener('DOMContentLoaded', fixAll);
})();