Batch Georeferencing - Randomly Select Batch

Add shuffle button to Symbiota "Batch Georeferencing Tools" page

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        Batch Georeferencing - Randomly Select Batch
// @description Add shuffle button to Symbiota "Batch Georeferencing Tools" page
// @namespace   symbiota.user.batchgeoref.rsb
// @include     */batchgeoreftool.php
// @author      Jack Willis
// @version     1.0
// @grant       none
// @license     MIT; https://opensource.org/licenses/MIT
// ==/UserScript==

$(function() {
  function sample(array) { return array[(Math.random() * array.length) | 0]; }
  
  var shuffleButton = $("<a>")
  .html("&#x1F500;") // shuffle emoji
  .css("margin-left", "10px").css("font-size", "18px")
  .hover(function() {
    $(this).css("cursor", "pointer").css("text-decoration", "none");  
  }).click(function(event) {
    event.preventDefault();
    $("#locallist option:selected").prop("selected", false); // deselect all batches
    $(sample($("#locallist option"))).prop("selected", true); // select random batch
  });
  
   // inject shuffle button in the panel above the <select>
  $("form[name=georefform] > div:first-child").append(shuffleButton);
});