Skip to content

Instantly share code, notes, and snippets.

@Amzd
Last active April 26, 2019 09:23
Show Gist options
  • Save Amzd/eb51289072e3d395a3d459d63d94656c to your computer and use it in GitHub Desktop.
Save Amzd/eb51289072e3d395a3d459d63d94656c to your computer and use it in GitHub Desktop.
Adds sorting buttons for Rocket League tracker players
// ==UserScript==
// @name Tracker Network Sort Players
// @namespace https://rocketleague.tracker.network
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://rocketleague.tracker.network/live*
// @grant GM_addStyle
// ==/UserScript==
$(function() {
'use strict';
$(".head").append('<h3>Sort Players by rank:</h3>');
$(".head").append('<a href="#" class="sorting-buttons">Duel 1v1</a>');
$(".head").append('<a href="#" class="sorting-buttons">Doubles 2v2</a>');
$(".head").append('<a href="#" class="sorting-buttons">Solo Standard 3v3</a>');
$(".head").append('<a href="#" class="sorting-buttons">Standard 3v3</a>');
$(".head").append('<a href="#" class="sorting-buttons"><i class="ion ion-close"></i></a>');
function sort() {
function sortDescending(a, b) {
var mmr1 = $(a).find(".current:visible").text().trim();
var mmr2 = $(b).find(".current:visible").text().trim();
return mmr1 < mmr2 ? 1 : -1;
}
$('.content [id^="player-"]').sort(sortDescending).appendTo('.content');
}
function filter(term) {
function filterStats() { return $(this).find(".title").text() == term || term == "" }
$('.content [id^="player-"] .rank-stat').hide().filter(filterStats).show();
function canShow(a) { return term == "" }
$('.content [id^="player-"] .small-stats').hide().filter(canShow).show();
$('.content [id^="player-"] .stat-group').hide().filter(canShow).show();
$('.content [id^="player-"]').css('width', '166px').css('display', 'inline-block').filter(canShow).css('width', '100%').css('display', 'block');
$('.content [id^="player-"] .card-tools a:contains("Profile")').hide().filter(canShow).show();
$('.content [id^="player-"]').css('margin-right', '10px');
}
$('.sorting-buttons').click(function(){
filter(this.text)
sort()
});
});
GM_addStyle ( `
.sorting-buttons, .sorting-buttons:active, .sorting-buttons:hover, .sorting-buttons:focus {
display: inline-block;
padding: 5px 10px;
text-decoration: none;
color: #fff;
background: #3f69d7;
border-radius: 2px;
transition: all .1s ease;
margin-right: 8px;
}
.sorting-buttons:hover {
background: #5479db;
box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),0 1px 5px 0 rgba(0,0,0,.12),0 3px 1px -2px rgba(0,0,0,.2);
}
.card-title {
overflow: hidden !important;
white-space: nowrap !important;
text-overflow: hidden !important;
height: 20px !important;
}
` );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment