You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

编写Greasemonkey脚本:日历可用日期出现时自动点击

Auto-Click Available Calendar Dates with Greasemonkey/Tampermonkey

Here's a script that will periodically check your calendar page for available dates (marked with the FULL class on the <td> element) and automatically click them as soon as they become accessible:

// ==UserScript==
// @name         Auto-Click Available Calendar Dates
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Automatically clicks available dates when they appear on the calendar
// @match        https://your-calendar-page-url.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    function checkAndClickAvailableDates() {
        // Target all unclicked available date links
        const availableDateLinks = document.querySelectorAll('td.FULL a:not(.already-clicked)');
        
        availableDateLinks.forEach(link => {
            // Trigger the click event (matches manual user interaction)
            link.click();
            // Mark the link as clicked to avoid repeated clicks
            link.classList.add('already-clicked');
            console.log(`Auto-clicked date: ${link.textContent.trim()}`);
        });
    }

    // Run the check immediately on script load
    checkAndClickAvailableDates();
    
    // Repeat the check every 1 second (1000ms) - adjust this value as needed
    setInterval(checkAndClickAvailableDates, 1000);
})();

Key Details & Customization Tips:

  • Target URL: Replace https://your-calendar-page-url.com/* in the @match line with the actual URL of your calendar page. This ensures the script only runs where it's needed.
  • Check Interval: The 1000 value in setInterval is the time between checks in milliseconds. If dates become available less frequently, you can increase this (e.g., 5000 for 5 seconds) to reduce unnecessary page checks. If they appear quickly, decrease it (but avoid going below 500ms to prevent performance issues).
  • Prevent Re-Clicks: The script adds an already-clicked class to each link after clicking it, so it won't click the same date multiple times. If you want to re-check dates (e.g., if the calendar resets), you can remove this part.
  • How It Works: The script looks for <a> elements inside <td> tags with the FULL class (the marker for available dates in your provided HTML). It simulates a user click, which triggers the schedule() function exactly like manual interaction would.

Installation Steps:

  1. Install Greasemonkey (Firefox) or Tampermonkey (Chrome/Edge) if you haven't already.
  2. Create a new userscript and paste the code above.
  3. Update the @match URL to your calendar page's URL.
  4. Save the script and navigate to your calendar page—it will start working automatically.

内容的提问来源于stack exchange,提问作者kinase

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:54:57