Relationship to JRC Date: add Today button

Add a button to the Relationship to JRC Date field that sets it to today's date.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Relationship to JRC Date: add Today button
// @namespace    https://github.com/nate-kean/
// @version      20251217
// @description  Add a button to the Relationship to JRC Date field that sets it to today's date.
// @author       Nate Kean
// @match        https://jamesriver.fellowshiponego.com/members/edit/*
// @match        https://jamesriver.fellowshiponego.com/members/add*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=fellowshiponego.com
// @grant        none
// @license      MIT
// @require      https://update.greasyfork.org/scripts/554804/1689525/Nate%27s%20Day%20Button.js
// @run-at       document-end
// ==/UserScript==

(async function() {
    document.head.insertAdjacentHTML("beforeend", `
        <style id="nates-today-button-css">
            .nates-day-button.today {
                float: right;
                margin-top: -2px;
            }
        </style>
    `);

    const FIELDS = [
        "Relationship to JRC Date",
        "Address Updated Date",
    ];

    function delay(ms) {
        return new Promise((resolve) => setTimeout(resolve, ms));
    }

    function getDateString() {
        return new Intl.DateTimeFormat("en-US", {
            month: "2-digit",
            day: "2-digit",
            year: "numeric",
        }).format(new Date());
    }

    for (const formGroup of document.querySelectorAll(".additional-info-panel .form-group")) {
        const name = formGroup.querySelector("label")?.textContent.trim();
        if (!FIELDS.includes(name)) continue;
        const btn = document.createElement("button");
        btn.classList.add("nates-day-button", "today");
        btn.textContent = "Today";
        btn.type = "button";
        btn.addEventListener("click", () => {
            formGroup.querySelector("input").value = getDateString();
        }, { passive: true });
        formGroup.prepend(btn);
    }
})();