Last active
December 10, 2025 03:01
-
-
Save donal56/74db423c6f7fb8919540c0bd6cdab32f to your computer and use it in GitHub Desktop.
Remove entries from wishlist without the whole page reloading
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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); | |
| }); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment