-
Notifications
You must be signed in to change notification settings - Fork 1
/
akashi_auto_fill.min.js
1 lines (1 loc) · 1.45 KB
/
akashi_auto_fill.min.js
1
javascript:(()=>{const e=!0;let t=function(){let t=[],r=(new Date).getFullYear();return document.querySelectorAll('tr[id^="working_report"]').forEach(u=>{let o=u.querySelectorAll('input[type="text"][name^="form[working_records_attributes]["]');if(!u.textContent.match(/休日/)&&2===o.length&&(e||""===o[0].value&&""===o[1].value)){let e=u.querySelector('td[rowspan="2"]').textContent.trim(),o=new Date(`${r}/${e}`),n=("0"+(o.getMonth()+1)).slice(-2),c=("0"+o.getDate()).slice(-2);t.push(`${r}-${n}-${c}`)}}),t}();if(0!==t.length){document.querySelector(`a[href="/working_records/new?date=${t[0]}"]`).click();var r=new MutationObserver(()=>(function(e){r.disconnect(),document.querySelector("button.js-remove-date-button").click(),e.forEach(e=>{document.querySelector('input[name="apply_date_value"]').value=e,document.querySelector("button.c-add-button").click()}),document.querySelector("#form_working_record_attributes_result_start_time_text").value="10:00",document.querySelector("#form_working_record_attributes_result_end_time_text").value="19:00",document.querySelector("#form_working_record_attributes_break_time_results_attributes_0_result_break_time_start_time_text").value="12:00",document.querySelector("#form_working_record_attributes_break_time_results_attributes_0_result_break_time_end_time_text").value="13:00",document.querySelector('input[type="submit"]').click()})(t));r.observe(document.getElementById("mask-default"),{attributes:!0,attributeFilter:["class"]})}})();