SB100 / PTP Upcoming Freeleech Queue Order

// ==UserScript==
// @namespace    https://openuserjs.org/users/SB100
// @name         PTP Upcoming Freeleech Queue Order
// @description  Adds a queue order column to the upcoming freeleech page
// @updateURL    https://openuserjs.org/meta/SB100/PTP_Upcoming_Freeleech_Queue_Order.meta.js
// @version      1.0.1
// @author       SB100
// @copyright    2021, SB100 (https://openuserjs.org/users/SB100)
// @license      MIT
// @match        https://passthepopcorn.me/bonus.php?action=viewupcomingfreeleech
// ==/UserScript==

// ==OpenUserJS==
// @author SB100
// ==/OpenUserJS==

/* jshint esversion: 6 */

(function () {
  'use strict';

  // add a header
  const th = document.createElement('th');
  th.classList.add('sorting');
  th.role = 'columnheader';
  th.ariaControls = 'finished-pots-table';
  th.ariaLabel = 'Queue: activate to sort column ascending';
  th.innerText = 'Queue';
  document.getElementById('finished-pots-table').querySelector('thead tr').prepend(th);

  // add the queue number to each row
  Array.from(document.getElementById('finished-pots-table').querySelectorAll('tbody tr')).forEach((tr, idx) => {
    const td = document.createElement('td');
    td.innerText = idx + 1;
    tr.prepend(td);
  });

  // destroy the current data table and recreate a new one
  unsafeWindow.$jq("#finished-pots-table").DataTable().fnDestroy();
  unsafeWindow.$jq("#finished-pots-table").dataTable({
    "bPaginate": false,
    "bInfo": false,
    "sDom": "lrtip", // hide the default filtering
    "bSortClasses": false, // to speed up the table, do not add sort classes
    "asStripeClasses": [], // do not add odd and even classes
    "aaSorting": [], // no initial sorting
    "aoColumns": [
      null,
      null,
      {
        "sType": "title-date"
      },
      {
        "sType": "title-date"
      },
      {
        "sType": "hiddentitle-numeric"
      },
      null
    ]
  });
})();