Copy start date to end date on time entry edit page
当前为
// ==UserScript==
// @name Moneybird - Copy start date to end date on time entry edit page
// @namespace http://tampermonkey.net/
// @version 1.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 window.onurlchange
// @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;
})();