Custom Suruga-ya

Remove entries from wishlist without the whole page reloading

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Custom Suruga-ya
// @namespace    http://tampermonkey.net/
// @version      2025-12-09
// @description  Remove entries from wishlist without the whole page reloading
// @author       Doni
// @match        https://www.suruga-ya.com/*/mypage/wishlist/detail/*
// @icon         https://www.suruga-ya.com/sites/default/files_light/pwa/images/icons/favicon-32x32.png.webp?v=1
// @grant        none
// ==/UserScript==

(function () {
    'use strict';

    const SELECTOR = 'span.ti-trash.delete-item';
    const DELETE_PATH = '/es/wishlist/delete/';

    async function handleClick(ev) {
        if (ev.button !== 0) return;

        ev.preventDefault();
        ev.stopImmediatePropagation();

        const itemId = ev.currentTarget.getAttribute('data-item_id');
        const link = ev.currentTarget.closest('a');

        if (!itemId) return;
        link.removeAttribute('href');
        link.parentElement.parentElement.remove();

        const deleteUrl = new URL(DELETE_PATH + encodeURIComponent(itemId), location.origin).href;
        fetch(deleteUrl, { method: 'GET', credentials: 'same-origin' })
            .catch(err => alert('Deletion error, please reload: ' + err));
    }

    document.querySelectorAll(SELECTOR).forEach(el => {
        el.addEventListener('click', handleClick, true);
    });

})();