Amazon Cart Item Remover

Add a button to remove all items in Amazon cart

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @license MIT
// @name         Amazon Cart Item Remover
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Add a button to remove all items in Amazon cart
// @author       Daniel
// @match        https://www.amazon.com/gp/cart/view.html*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Crear el botón y establecer su texto y estilo
    var button = document.createElement('button');
    button.innerHTML = 'Eliminar todos los artículos';
    button.style.width = '200px';
    button.style.height = '40px';
    button.style.position = 'absolute';
    button.style.top = '5px';
    button.style.right = '5px';

    // Añadir el evento click al botón
    button.onclick = function(){
        // Obtener todos los enlaces de eliminación
        var deleteLinks = document.querySelectorAll('input[name="submit.delete.CURRENT"]');
        for (var i = 0; i < deleteLinks.length; i++) {
            // Hacer clic en cada enlace de eliminación
            deleteLinks[i].click();
        }
    }

    // Añadir el botón al body de la página
    document.body.appendChild(button);

})();