Greasy Fork 支持简体中文。

Next Spaceflight Countdown

Adds a countdown timer to upcoming space launches on NextSpaceflight.com

作者
Cochinver
今日安裝
1
安裝總數
1
評價
0 0 0
版本
1.1
建立日期
2025-02-26
更新日期
2025-02-26
尺寸
1.9 KB
授權條款
未知
腳本執行於

Next Spaceflight Countdown Userscript

Description

This userscript adds a countdown timer to elements on NextSpaceflight.com.

Functionality

  • The script selects all elements with the class mdl-card.
  • It searches for a span element inside each card where the id starts with "localized".
  • If found, it attempts to parse the textContent of this element as a date.
  • If the date is valid, the script calculates the time difference between the current time and the parsed date.
  • The script looks for an element with the class csscolumns inside the card:
    • If found, it checks if an element with the class countdown-tag already exists.
    • If not, it creates a new div element with this class and appends it to the csscolumns container.
  • The countdown timer is displayed in the format T-[days]d [hours]h [minutes]m [seconds]s and updates every second.

Execution

  • The script runs immediately when the page is loaded.
  • It updates the countdown every second using setTimeout to adjust for millisecond precision.

Page Matching

Permissions

  • The script does not request any special permissions (@grant none).

Notes

  • If the required elements are not found or the parsed date is invalid, the script does nothing.