Custom Suruga-ya

Remove entries from wishlist without the whole page reloading

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==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);
    });

})();