Greasy Fork

Amazon eBook "Download & transfer via USB" easy device click

When downloading Amazon eBooks ("Content & Devices" -> "Books" -> "More actions" -> "Download & transfer via USB") you can now click in the whole box of the device instead of just the little radio button

当前为 2024-02-04 提交的版本,查看 最新版本

// ==UserScript==
// @name         Amazon eBook "Download & transfer via USB" easy device click
// @namespace    MKScripts
// @version      1.1
// @description  When downloading Amazon eBooks ("Content & Devices" -> "Books" -> "More actions" -> "Download & transfer via USB") you can now click in the whole box of the device instead of just the little radio button
// @author       MKScripts
// @match        https://www.amazon.*/hz/mycd/digital-console/contentlist/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Add click event listener to the document body for event delegation
    document.body.addEventListener('click', function (event) {
      // Check if the clicked element is an <li> and contains a radio button
      var isActionListItem = event.target.tagName === 'LI' && event.target.querySelector('input[type="radio"]');

      if (isActionListItem) {
        // Find the radio button within the clicked LI
        var radioButton = event.target.querySelector('input[type="radio"]');

        // Check the radio button if it exists
        if (radioButton) {
          // Simulate a click event on the radio button
          radioButton.click();
        }
      }
    });

})();