Greasy Fork

Greasy Fork is available in English.

Highlight Playable Events on Limitless TCG

Highlights weekend events on play.limitlesstcg.com

当前为 2023-05-22 提交的版本,查看 最新版本

// ==UserScript==
// @name         Highlight Playable Events on Limitless TCG
// @namespace    http://www.example.com
// @version      1.0
// @description  Highlights weekend events on play.limitlesstcg.com
// @author       Joe Zhu
// @match        https://play.limitlesstcg.com/tournaments/upcoming*
// @grant        none
// @license      joezhuu
// ==/UserScript==

(function() {
    'use strict';

    // Function to check if a date falls on a weekend (Saturday or Sunday)
    function isSuitable(date) {
        const day = date.getDay();
        const hour = date.getHours();
        // Sat or Sun is good
        if (day === 0 || day === 6) {
            // from 8am to 5pm
            if (hour >= 8 && hour <= 17)
            {
                return true;
            }
        }
        return false;
    }

    // Get the event table
    const eventTable = document.querySelector('table.striped.upcoming-tournaments'); // Update this selector if needed

    // Get all the event rows
    const eventRows = eventTable.querySelectorAll('tr[data-date]');

    // Loop through each event row
    eventRows.forEach(row => {
        // Get the date of the event
        const dateString = row.getAttribute('data-date');
        const eventDate = new Date(dateString);

        // Check if the event falls on a weekend
        if (isSuitable(eventDate)) {
            // Apply highlighting to the event row
            row.style.color = '#FF00CC';
        }
    });
})();