您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Сортировка комментариев по рейтингу для geektimes и habrahabr
// ==UserScript== // @name Сортировка комментариев // @version 0.7 // @description Сортировка комментариев по рейтингу для geektimes и habrahabr // @author Saikava // @include https://geektimes.ru* // @include https://habrahabr.ru* // @include https://habr.com* // @include https://geektimes.com* // @namespace Сортировка комментариев по рейтингу для geektimes и habrahabr // ==/UserScript== (function() { function sortComments(){ var comments = $('.js-comment'); var commentVotes = []; comments.each(function(i,e){ commentVotes.push(parseInt($(e).find('.js-score').first().text().replace('–', '-'))); }); for (var i = 0; i < commentVotes.length; i++){ var max = commentVotes[i]; var indexOfMax = i; for (var j = i + 1; j < commentVotes.length; j++){ if (commentVotes[j] > max){ max = commentVotes[j]; indexOfMax = j; } } var topComment = comments[indexOfMax]; comments[indexOfMax] = comments[i]; commentVotes[indexOfMax] = commentVotes[i]; $('#comments-list').append(topComment); } $('#sortCommentsButton').hide(); } if ($('#comments').length > 0){ $('#comments header').append('<button id="sortCommentsButton">Сортировать</button>'); $('#sortCommentsButton').click(sortComments); } }());