Better Games Done Quick Schedule

try to take over the world!

目前為 2017-01-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Better Games Done Quick Schedule
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  try to take over the world!
// @author       You
// @match        https://gamesdonequick.com/schedule
// @grant        none
// @require http://code.jquery.com/jquery-latest.js
// ==/UserScript==

(function() {
    'use strict';

    console.log("Better AGDQ Shedule loading...");
    var tableRows = $("#runTable tbody tr");
    var time = "";
    var day = 0;
    var currentDate = new Date($.now());
    var rowOfCurrentRun = 0;
    console.log("Collecting and formatting dates and times...");
    for(var i = 0; i < tableRows.length; i = i +2)
    {
        if(tableRows.eq(i).hasClass("day-split"))
        {
            day = tableRows.eq(i).text().match(/\d+/)[0];
            i++;
            continue;
        }
        time = timeFormatting(tableRows.eq(i).children().eq(0).text());
        var date="2017/01/" + day +" " + time;
        var newDate = new Date(Date.parse(date));
        if(currentDate < newDate)
        {
            console.log("Highlighting current runs...");
            //console.log(newDate);
            //console.log(currentDate);
            //console.log(tableRows.eq(i-2));
            //console.log(tableRows.eq(i-1));
            //Ändere Background vom vorheriger Run
            tableRows.eq(i-4).css("background-color", "#f2dede");
            tableRows.eq(i-4).css("color", "black");
            if(tableRows.eq(i-3).hasClass("day-split"))
            {
                tableRows.eq(i-5).css("background-color", "#f2dede");
                tableRows.eq(i-5).css("color", "black");
                $(tableRows.eq(i-5)).attr('id', 'currentRun');
            }
            else
            {
                tableRows.eq(i-3).css("background-color", "#f2dede");
                tableRows.eq(i-3).css("color", "black");
                $(tableRows.eq(i-4)).attr('id', 'currentRun');
            }
            //Ändere Background vom aktuellem Run
            tableRows.eq(i-2).css("background-color", "#a00303");
            tableRows.eq(i-2).css("color", "white");
            tableRows.eq(i-1).css("background-color", "#a00303");
            tableRows.eq(i-1).css("color", "white");
            //Ändere Background vom nächsten Run
            if(tableRows.eq(i).hasClass("day-split"))
            {
                tableRows.eq(i+2).css("background-color", "#f2dede");
                tableRows.eq(i+2).css("color", "black");
            }
            else
            {
                tableRows.eq(i).css("background-color", "#f2dede");
                tableRows.eq(i).css("color", "black");
            }
            tableRows.eq(i+1).css("background-color", "#f2dede");
            tableRows.eq(i+1).css("color", "black");
            rowOfCurrentRun = i;
            i = tableRows.length;
        }
    }
    console.log("Adding current run to the top of the page...");
    //Den aktuellen RUN an den Anfang der Seite einfügen
    var top = $(tableRows.eq(rowOfCurrentRun-2)).children();
    var bottom = $(tableRows.eq(rowOfCurrentRun-1)).children();
    var goToCurrentRun = "<a href='#currentRun' id='goToCurrentRun' style='display: inline-block; text-align: center; padding: 5px 20px; color: white; line-height: 25px; padding-left: 15px; height: 100%; width: 150px; text-decoration: none; background-color: #8c1616;'>Go to Current Run <img style='filter: invert(); width: 20px; height: 22px' src='https://cdn0.iconfinder.com/data/icons/navigation-set-arrows-part-one/32/DoubleChevronDown-128.png'/></a>";
    var currentRun = "<div style='overflow-x: auto; display: inline-block; max-width: 100%; vertical-align: top;'><nobr><div style='background-color: #a00303; color: white; padding: 5px 20px; line-height: 25px; display: inline-block;'>Current Run: <b>" + top.eq(1).text() + " (" + bottom.eq(1).text() + ")</b>&emsp;From <b>" + top.eq(2).text() + "</b><br/>Start: <b>" + timeFormatting(top.eq(0).text()) + "&emsp;</b> Duration: <b>" + timeFormatting(bottom.eq(0).text()) + "&emsp;</b> Setup Length: <b>" + timeFormatting(top.eq(3).text()) + "</b></div></nobr></div>" + goToCurrentRun;

    $("#top").after(currentRun);
    //console.log($("#white-bg").eq(2));
    $("#goToCurrentRun").mouseenter(function() {
        $(this).css("background-color", "#c32323");
    }).mouseleave(function() {
        $(this).css("background-color", "#8c1616");
    });
    console.log("Better AGDQ Shedule done");
}
 )();

function timeFormatting(time)
{
    //console.log("TimeFormatting:" + time);
    //console.log("Länge: " + time.length);
    //console.log(time);
    if(time.length == 7)
    {
        time = "0" + time;
    }
    else if(time.length == 10)
    {
        time = time.replace(/  /g, "0");
    }
    else
    {
        time = time;
    }
    return time;
}