您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Sort TF.TV posts by frag count
// ==UserScript== // @name TF.TV sort by frag count // @namespace sheybey // @description Sort TF.TV posts by frag count // @include https://www.teamfortress.tv/* // @version 1.0.2 // @grant none // ==/UserScript== (function () { 'use strict'; var container = document.getElementById('thread-container'); function create_option(name, value) { var option = document.createElement('option'); option.value = value; option.textContent = name; return option; } if (container !== null) { var select = document.createElement('select'); select.appendChild(create_option('Sort by date', 'date')); select.appendChild(create_option('Sort by frags', 'frags')); select.style.marginBottom = '0'; select.style.width = '110px'; select.addEventListener('change', function () { var posts = Array.from(container.children); var cmp; function frag_count(post) { if (post.classList.contains('self')) { return Infinity; } return parseInt( post.querySelector('.post-frag-count').textContent, 10 ); } function post_id(post) { return parseInt(post.firstElementChild.id, 10); } if (select.value === 'frags') { cmp = function (a, b) { return frag_count(b) - frag_count(a); }; } else { cmp = function (a, b) { return post_id(a) - post_id(b); }; } posts.sort(cmp); posts.forEach(function (post) { container.appendChild(post); }); }); document.querySelector('.thread-frag-container').appendChild(select); } }());