Amazon Cart Item Remover

Add a button to remove all items in Amazon cart

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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);

})();