Toranoana: no reload

Do not redirect after action.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Toranoana: no reload
// @namespace    http://darkfader.net/
// @version      0.3
// @description  Do not redirect after action.
// @author       Rafael Vuijk
// @match        https://ec.toranoana.shop/ec/app/mypage/favorite_list/*
// @match        https://ec.toranoana.shop/ec/app/cart/cart/*
// @grant        unsafeWindow
// ==/UserScript==

HTMLElement.prototype.remove = function() { this.parentNode.removeChild(this); return this; }

function onReady() {
    const _controlAjaxSuccess = unsafeWindow.controlAjaxSuccess;
    unsafeWindow.controlAjaxSuccess = function(data, successFunction, messageType, messageAdd, formId) {
        if (formId !== undefined && formId != null) {
            console.log("controlAjaxSuccess", data, successFunction, messageType, messageAdd, formId);
            let action = document.getElementById(formId).querySelector("input[name='actionId']").value;
            console.log(data, action);
            if (action == "delete") {
                data.nextUrl = null; // don't go anywhere (and parse transactiontoken from result)
            }
            _controlAjaxSuccess(data, successFunction, messageType, messageAdd, formId);
            if (action == "delete") {
                document.getElementById(formId).remove();
            }
        } else {
            _controlAjaxSuccess(data, successFunction, messageType, messageAdd, formId);
        }
    }
}

// start the onReady...
if (document.readyState !== "loading") {
    setTimeout(onReady, 0);
} else {
    document.addEventListener("DOMContentLoaded", onReady);
}