LibraryThing add ten authors at a time

A shortcut for adding multiple "Other authors" inputs at once

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        LibraryThing add ten authors at a time
// @description A shortcut for adding multiple "Other authors" inputs at once
// @namespace   https://greasyfork.org/en/users/11592-max-starkenburg
// @include     http*://*librarything.tld/work/*edit/*
// @include     http*://*librarything.com/work/*edit/*
// @include     http*://*librarything.tld/addnew.php*
// @include     http*://*librarything.com/addnew.php*
// @version     2
// @grant       none
// ==/UserScript==

// Find the "add another author" link and put a "add another 10 authors" link next to it
var addAnotherAuthor = document.evaluate(
  '//div[@id="addPersonControl"]//a',
  document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
if (addAnotherAuthor.snapshotLength > 0) {
  addAnotherAuthor = addAnotherAuthor.snapshotItem(0);    
  addTenAuthors = document.createElement('span');
  addTenAuthors.innerHTML = ' | <a href="javascript:addTenPersons();">add another 10 authors</a>'
  var par = addAnotherAuthor.parentNode;
  par.insertBefore(addTenAuthors, addAnotherAuthor.nextSibling);    
}

// Append to the document body the function that repeats addPerson() 10 times
var body = document.getElementsByTagName("body")[0];
var script = document.createElement("script");
script.type = "text/javascript";
script.innerHTML = '\
  function addTenPersons() {\
    for (var i=0; i<10; i++) {\
      addPerson();\
    }\
  }\
  ';
body.appendChild(script);