Untitled
unknown
plain_text
3 years ago
1.8 kB
9
Indexable
(function () {
try {
/* main variables */
var debug = 0;
var variation_name = "";
/* all Pure helper functions */
function waitForElement(selector, trigger, delayInterval, delayTimeout) {
var interval = setInterval(function () {
if (
document &&
document.querySelector(selector) &&
document.querySelectorAll(selector).length > 0
) {
clearInterval(interval);
trigger();
}
}, delayInterval);
setTimeout(function () {
clearInterval(interval);
}, delayTimeout);
}
function init(){
const send = XMLHttpRequest.prototype.send
XMLHttpRequest.prototype.send = function() {
this.addEventListener('load', function() {
console.log(this.responseURL, 'global handler', this.responseText)
if(this.responseURL.indexOf('https://www.bevilles.com.au/cart.js') !=-1 || this.responseURL.indexOf('https://www.bevilles.com.au/cart/add.js') !=-1){
waitForElement("#colorbox, #cboxOverlay", moveCart, 50, 15000);
}
// add your global handler here
})
return send.apply(this, arguments)
}
}
function moveCart(){
document.querySelector('#colorbox').style.display ="none"
window.location.href = '/cart';
}
/* Initialize variation */
waitForElement(".btn.product-add, .quick-buy.giant-round-button", init, 50, 15000);
} catch (e) {
if (debug) console.log(e, "error in Test" + variation_name);
}
})();Editor is loading...