Mark scheduled games as favorites in AGDQ

It's hard to keep track of favorite games, with this script you can click to highlight games.

当前为 2016-06-30 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Mark scheduled games as favorites in AGDQ
// @description  It's hard to keep track of favorite games, with this script you can click to highlight games.
// @namespace    http://gamesdonequick.com/
// @version      0.1
// @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) {
            last = [e.pageX, e.pageY];
        });

        rows.on('mouseup', function(e) {
            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);