Mark scheduled games as favorites in Games Done Quick

With this script you can click to highlight your favorite games in the GDQ schedule list.

As of 17.08.2020. See ბოლო ვერსია.

// ==UserScript==
// @name         Mark scheduled games as favorites in Games Done Quick
// @description  With this script you can click to highlight your favorite games in the GDQ schedule list.
// @namespace    http://gamesdonequick.com/
// @version      0.2
// @author       ciscoheat
// @match        https://gamesdonequick.com/schedule
// @grant        none
// ==/UserScript==

(function($) {
    'use strict';

    var selected = localStorage.favorites ? JSON.parse(localStorage.favorites) : [];

    $("#runTable .start-time").closest('tr').each(function(_, tr) {
        var secondRow = $(tr).next();
        var game = $(tr).find('.start-time + td').text();
        var rows = $(tr).add(secondRow);
        var last = [];

        if(selected.indexOf(game) >= 0) rows.css('background-color', '#c0f9c2');

        rows.on('mousedown', function(e) {
			if(e.button != 0) return;
            last = [e.pageX, e.pageY];
        });

        rows.on('mouseup', function(e) {
			if(e.button != 0) return;
            if(Math.abs(e.pageX - last[0]) > 2 || Math.abs(e.pageY - last[1]) > 2) return;

            var pos = selected.indexOf(game);

            if(pos < 0) {
                selected.push(game);
                rows.css('background-color', '#c0f9c2');
            } else {
                selected.splice(pos, 1);
                rows.css('background-color', '');
            }

            localStorage.favorites = JSON.stringify(selected);
        });
    });
})(jQuery);