Greasy Fork

TFGamesSite Sort By Likes

When searching on tfgames.site, sort by number of likes.

目前为 2020-12-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         TFGamesSite Sort By Likes
// @namespace    https://github.com/imaginary-upside
// @version      0.1
// @description  When searching on tfgames.site, sort by number of likes.
// @author       imaginary-upside
// @match        https://tfgames.site/index.php?module=search&*
// @match        https://tfgames.site/?module=search&*
// @grant        none
// ==/UserScript==

function getLikes(row) {
  return parseInt(row.children[4].innerText);
}

var rows = Array.from(document.querySelectorAll("tbody tr"));
rows.sort(function(a, b) {
  return getLikes(b) - getLikes(a);
});
rows.forEach(row => {
  document.querySelector("tbody").appendChild(row);
});