(Script) Select all novels in a reading list

Discussion in 'Novel Updates Site Discussion' started by admira, Jul 9, 2016.

Thread Status:
Not open for further replies.
  1. admira

    admira Dino Pirate

    Joined:
    Nov 8, 2015
    Messages:
    576
    Likes Received:
    491
    Reading List:
    Link
    Long story short, I wanted to select all novels in a reading list at once so I could move them. So, enter JavaScript.

    Since I was too lazy to do any more JS than absolutely necessary (which, in this case, was none at all), @noisypixy has provided an alternative that doesn't mess with the other checkboxes:
    Code:
    // Select the element that contains your reading list.
    var readingList = document.getElementById('myTable read');
    
    // Select the checkboxes from your reading list.
    var checkboxes = readingList.querySelectorAll('input[type="checkbox"]');
    
    // Convert the `checkboxes` variable to a "normal" array,
    // so we can use the `forEach` method.
    checkboxes = Array.prototype.slice.call(checkboxes);
    
    // Walk over every checkbox...
    checkboxes.forEach(function(el) {
      // ... and enable it.
      el.checked = true;
    });
    Previous:
    Luckily, I didn't have to write the script myself; I found it on Stack Overflow:
    Code:
    (function() {
        var aa = document.querySelectorAll("input[type=checkbox]");
        for (var i = 0; i < aa.length; i++){
            aa[i].checked = true;
        }
    })()
    WARNING: This also affects checkboxes under the settings popups. However, this isn't a problem unless you click the "Save Settings" button. Refreshing will reset the checkboxes to the saved settings.

    To use, bring up developer tools in your browser and paste the code in the console window. This works with Chrome, at least.

    And always, always use caution when utilizing code that other people have written, especially if you can't see the source. In this case, the only thing this script does is find every checkbox in the reading list and set it to checked.
     
    Last edited: Jul 10, 2016
    Ophious and Shio like this.
  2. Ophious

    Ophious 〖Aliceshiki's Disciple〗〖Victim of Raneday〗

    Joined:
    Dec 31, 2015
    Messages:
    2,828
    Likes Received:
    18,554
    Reading List:
    Link
Thread Status:
Not open for further replies.