Created
June 20, 2014 03:06
-
-
Save ken39arg/5bdfa26c65fe63bd119e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name ZAC Emphasize | |
| // @version 0.1 | |
| // @copyright nagata-hiroaki@kayac.com | |
| // @namespace http://handlena.me | |
| // @description This script bring little better ZAC to you. | |
| // @include https://asp19.jp.oro.com/kayac/Shinsei/Nippou.asp* | |
| // ==/UserScript== | |
| document.getElementsByXPath = function(expression, parentElement) { | |
| var r = []; | |
| var x = document.evaluate(expression, parentElement || document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | |
| for (var i = 0, l = x.snapshotLength; i < l; i++) { | |
| r.push(x.snapshotItem(i)); | |
| } | |
| return r; | |
| }; | |
| // 上段のテーブルを下段に合わせる | |
| var table_upper = document.getElementsByXPath('html/body/form[2]/table[2]/tbody/tr/td/table[1]/tbody/tr[2]/td/table')[0]; | |
| table_upper.width = null; | |
| // 作業内容入力欄を広げる | |
| var table_lower = document.getElementsByXPath('html/body/form[2]/table[2]/tbody/tr/td/table[2]/tbody/tr[2]/td/div')[0]; | |
| console.log(table_lower); | |
| table_lower.style.height = '1200px'; | |
| // 作業時間 | |
| var start_hour = 9, | |
| start_minute = 30, | |
| end_hour = 20, | |
| end_minute = 0, | |
| rest_hour = 1, | |
| rest_minute = 0, | |
| work_hour = ( end_hour - start_hour - rest_hour ), | |
| work_minute = end_minute - start_minute - rest_minute; | |
| if ( work_minute < 0 ) { | |
| work_hour--; | |
| work_minute += 60; | |
| } | |
| // 自動入力 | |
| var input = { | |
| in_h: document.getElementsByXPath('//select[@name="time_in_hour"]/option[@value="'+start_hour+'"]')[0], | |
| in_m: document.getElementsByXPath('//select[@name="time_in_minute"]/option[@value="'+start_minute+'"]')[0], | |
| out_h: document.getElementsByXPath('//select[@name="time_out_hour"]/option[@value="'+end_hour+'"]')[0], | |
| out_m: document.getElementsByXPath('//select[@name="time_out_minute"]/option[@value="'+end_minute+'"]')[0], | |
| rest_h: document.getElementsByXPath('//select[@name="time_break_input_hour"]/option[@value="'+rest_hour+'"]')[0], | |
| rest_m: document.getElementsByXPath('//select[@name="time_break_input_minute"]/option[@value="'+rest_minute+'"]')[0], | |
| work_h: document.getElementsByXPath('//select[@name="time_required_hour1"]/option[@value="'+work_hour+'"]')[0], | |
| work_m: document.getElementsByXPath('//select[@name="time_required_minute1"]/option[@value="'+work_minute+'"]')[0], | |
| type: [ | |
| document.getElementsByXPath('html/body/form[2]/table[2]/tbody/tr/td/table[2]/tbody/tr[2]/td/div/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td[1]/div/select')[0], | |
| document.getElementsByXPath('html/body/form[2]/table[2]/tbody/tr/td/table[2]/tbody/tr[2]/td/div/table/tbody/tr[3]/td[2]/table/tbody/tr[2]/td[1]/div/select')[0], | |
| document.getElementsByXPath('html/body/form[2]/table[2]/tbody/tr/td/table[2]/tbody/tr[2]/td/div/table/tbody/tr[4]/td[2]/table/tbody/tr[2]/td[1]/div/select')[0], | |
| document.getElementsByXPath('html/body/form[2]/table[2]/tbody/tr/td/table[2]/tbody/tr[2]/td/div/table/tbody/tr[5]/td[2]/table/tbody/tr[2]/td[1]/div/select')[0], | |
| document.getElementsByXPath('html/body/form[2]/table[2]/tbody/tr/td/table[2]/tbody/tr[2]/td/div/table/tbody/tr[6]/td[2]/table/tbody/tr[2]/td[1]/div/select')[0], | |
| document.getElementsByXPath('html/body/form[2]/table[2]/tbody/tr/td/table[2]/tbody/tr[2]/td/div/table/tbody/tr[7]/td[2]/table/tbody/tr[2]/td[1]/div/select')[0], | |
| document.getElementsByXPath('html/body/form[2]/table[2]/tbody/tr/td/table[2]/tbody/tr[2]/td/div/table/tbody/tr[8]/td[2]/table/tbody/tr[2]/td[1]/div/select')[0], | |
| document.getElementsByXPath('html/body/form[2]/table[2]/tbody/tr/td/table[2]/tbody/tr[2]/td/div/table/tbody/tr[9]/td[2]/table/tbody/tr[2]/td[1]/div/select')[0], | |
| document.getElementsByXPath('html/body/form[2]/table[2]/tbody/tr/td/table[2]/tbody/tr[2]/td/div/table/tbody/tr[10]/td[2]/table/tbody/tr[2]/td[1]/div/select')[0] | |
| ] | |
| }; | |
| var button = document.createElement('button'); | |
| var main_table = document.getElementsByXPath('/html/body/form[2]/table[2]/tbody/tr/td/table[1]/tbody/tr[2]/td/table')[0]; | |
| button.innerHTML = 'auto input'; | |
| button.style.position = 'absolute'; | |
| button.style.top = '96px'; | |
| button.style.right = '6px'; | |
| button.style.height = (window.innerHeight - 96) + 'px'; | |
| button.style.width = (window.innerWidth - main_table.offsetWidth - 20) + 'px'; | |
| button.style.fontSize = 'large'; | |
| button.style.zIndex = 2000000; | |
| button.addEventListener('click', function() { | |
| input.in_h.selected = true; | |
| input.in_m.selected = true; | |
| input.out_h.selected = true; | |
| input.out_m.selected = true; | |
| input.rest_h.selected = true; | |
| input.rest_m.selected = true; | |
| input.work_h.selected = true; | |
| input.work_m.selected = true; | |
| //input.content.value = ''; | |
| for (var i = 0; i < input.type.length; ++i) { | |
| input.type[i].value = ''; | |
| } | |
| }, true); | |
| document.body.appendChild(button); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment