Autofill workload

Autofill platform.levtech.jp worklog

  1. // ==UserScript==
  2. // @name Autofill workload
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description Autofill platform.levtech.jp worklog
  6. // @author topaz2
  7. // @match https://platform.levtech.jp/p/workreport/input/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var year = $('p.reportTop__list__data__txtInput').text().replace(/[^\d]+/g, '').slice(0, 4),
  15. month = parseInt($('p.reportTop__list__data__txtInput').text().replace(/[^\d]+/g, '').slice(4, 6)),
  16. now = new Date(year, month - 1, 1), day, target,
  17. zeroPad = function(number, length){
  18. return (Array(length).join('0') + number).slice(-length);
  19. };
  20.  
  21. for (var d in [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31]) {
  22. day = new Date(now.getFullYear(), now.getMonth(), d).getDay();
  23. if (day === 0 || day ===6) continue;
  24. target = '#' + now.getFullYear() + zeroPad((now.getMonth() + 1), 2) + zeroPad(d, 2);
  25. if ($(target + 'start_time').val() === '' && $(target + 'end_time').val() === '' && $(target + 'relax_time').val() === '') {
  26. $(target + 'start_time').val('10:00');
  27. $(target + 'end_time').val('19:00');
  28. $(target + 'relax_time').val('01:00');
  29. }
  30. }
  31. })();