mlpnlp Table Sorter

mlpnlp の正誤表をページ番号順にソートする

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         mlpnlp Table Sorter
// @namespace    https://github.com/kyunashige/mlpnlp-table-sorter
// @version      0.3
// @description  mlpnlp の正誤表をページ番号順にソートする
// @author       kyuna
// @match        https://github.com/mlpnlp/mlpnlp
// @license      MIT
// @supportURL   https://github.com/kyunashige/mlpnlp-table-sorter/issues
// @grant        none
// ==/UserScript==

(() => {
  "use strict";
  /**
   * fetch correct/incorrect table
   */
  const $ = document.querySelector.bind(document);
  const coricTable = $("#readme > div > article > table > tbody");
  // console.log(toString.call(coricTable));
  /**
   * sort by PageNo
   */
  const rows = Array.prototype.slice.call(
    coricTable.getElementsByTagName("tr")
  );
  const getPageNo = (row) => {
    return parseInt(row.cells[2].innerText.match(/\d+/g)[0]);
  };
  rows.sort((a, b) => {
    return getPageNo(a) - getPageNo(b);
  });
  /**
   * create table
   */
  const tbody = $("tbody");
  for (const row of rows) {
    tbody.appendChild(row);
  }
  /**
   * replace table
   */
  $("#readme > div > article > table").appendChild(tbody);
})();