Moneybird - Copy start date to end date on time entry edit page

Copy start date to end date on time entry edit page

目前为 2023-06-09 提交的版本。查看 最新版本

// ==UserScript==
// @name         Moneybird - Copy start date to end date on time entry edit page
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  Copy start date to end date on time entry edit page
// @icon         https://assets2.sorryapp.com/brand_favicons/files/000/004/522/original/favicon-32.png
// @grant        none
// @author       pindab0ter
// @match        https://moneybird.com/*
// @license      MIT
// @run-at       document-start
// ==/UserScript==

(function () {
    'use strict';

    // Function to handle copying the start date to the end date
    function copyStartDateToEndDate() {
        const startedAtDateInput = document.getElementById('time_entry_started_at')
            ?.parentElement?.parentElement?.getElementsByClassName('date-picker__input')?.item(0);
        const endedAtDateInput = document.getElementById('time_entry_ended_at')
            ?.parentElement?.parentElement?.getElementsByClassName('date-picker__input')?.item(0);

        if (startedAtDateInput && endedAtDateInput?.value === "") {
            endedAtDateInput.value = startedAtDateInput.value;
        }
    }

    // Check if we’re on the time entry edit page
    function checkTimeEntryEditPage() {
        console.log('Triggered!');
        if (window.location.pathname.match(/time_entries\/\d+\/edit/)) {
            copyStartDateToEndDate();
        }
    }

    // Listen for URL changes
    window.onurlchange = checkTimeEntryEditPage;
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址