-
Notifications
You must be signed in to change notification settings - Fork 0
/
macro4.js
150 lines (142 loc) · 6.92 KB
/
macro4.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
function waitForElementToDisplay (selector, callback) {
const startTimeInMs = Date.now();
(function loopSearch () {
if (document.querySelector(selector) != null) {
return callback
} else {
setTimeout(function () {
if (10000 && Date.now() - startTimeInMs > 10000) {
return
}
loopSearch()
}, 250)
}
})()
}
function simulateMouseClick (targetNode) {
function triggerMouseEvent (targetNode, eventType) {
const clickEvent = document.createEvent('MouseEvents')
clickEvent.initEvent(eventType, true, true)
targetNode.dispatchEvent(clickEvent)
}
['mouseover', 'mousedown', 'mouseup', 'click'].forEach(function (eventType) {
triggerMouseEvent(targetNode, eventType)
})
}
function wip () {
if (document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item') != null) {
document.querySelector('#MM_Hang').click()
setTimeout(function () {
waitForElementToDisplay(('#MinAutoRecall_Button0_span'), simulateMouseClick(document.querySelector('#MinAutoRecall_Button0_span')))
}, 4000)
} else {
document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item').click()
document.querySelector('#MM_Hang').click()
setTimeout(function () {
waitForElementToDisplay(('#MinAutoRecall_Button0_span'), simulateMouseClick(document.querySelector('#MinAutoRecall_Button0_span')))
}, 4000)
}
}
function cliente () {
if (document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item') != null) {
document.querySelector('#MM_Hang').click()
setTimeout(function () {
waitForElementToDisplay(('#MinAutoRecall_Button2_span'), simulateMouseClick(document.querySelector('#MinAutoRecall_Button2_span')))
}, 4000)
} else {
document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item').click()
document.querySelector('#MM_Hang').click()
setTimeout(function () {
waitForElementToDisplay(('#MinAutoRecall_Button2_span'), simulateMouseClick(document.querySelector('#MinAutoRecall_Button2_span')))
}, 4000)
}
}
function rifiuto () {
if (document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item') != null) {
document.querySelector('#MM_Hang').click()
setTimeout(function () {
waitForElementToDisplay(('#MinAutoRecall_Button3_span'), simulateMouseClick(document.querySelector('#MinAutoRecall_Button3_span')))
}, 4000)
} else {
document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item').click()
document.querySelector('#MM_Hang').click()
setTimeout(function () {
waitForElementToDisplay(('#MinAutoRecall_Button3_span'), simulateMouseClick(document.querySelector('#MinAutoRecall_Button3_span')))
}, 4000)
}
}
function cambiocliente () {
if (document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item') != null) {
document.querySelector('#MM_Hang').click()
waitForElementToDisplay(('#Esito_IDStato_t'), simulateMouseClick(document.querySelector('#Esito_IDStato_t_Img')))
setTimeout(function () {
waitForElementToDisplay(('#tbody_Esito_IDStato > tr:nth-child(20) > td:nth-child(2)'), simulateMouseClick(document.querySelector('#tbody_Esito_IDStato > tr:nth-child(20) > td:nth-child(2)')))
waitForElementToDisplay(('#Esito_MotivoRifiuto_t'), simulateMouseClick(document.querySelector('#Esito_ConfermaEsito_span')))
}, 4000)
} else {
document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item').click()
document.querySelector('#MM_Hang').click()
waitForElementToDisplay(('#Esito_IDStato_t'), simulateMouseClick(document.querySelector('#Esito_IDStato_t_Img')))
setTimeout(function () {
waitForElementToDisplay(('#tbody_Esito_IDStato > tr:nth-child(20) > td:nth-child(2)'), simulateMouseClick(document.querySelector('#tbody_Esito_IDStato > tr:nth-child(20) > td:nth-child(2)')))
waitForElementToDisplay(('#Esito_MotivoRifiuto_t'), simulateMouseClick(document.querySelector('#Esito_ConfermaEsito_span')))
}, 4000)
}
}
function noretefissa () {
if (document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item') != null) {
document.querySelector('#MM_Hang').click()
waitForElementToDisplay(('#Esito_IDStato_t'), simulateMouseClick(document.querySelector('#Esito_IDStato_t_Img')))
setTimeout(function () {
waitForElementToDisplay(('#tbody_Esito_IDStato > tr:nth-child(16) > td:nth-child(2)'), simulateMouseClick(document.querySelector('#tbody_Esito_IDStato > tr:nth-child(16) > td:nth-child(2)')))
waitForElementToDisplay(('#Esito_MotivoRifiuto_t'), simulateMouseClick(document.querySelector('#Esito_ConfermaEsito_span')))
}, 4000)
} else {
document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item').click()
document.querySelector('#MM_Hang').click()
waitForElementToDisplay(('#Esito_IDStato_t'), simulateMouseClick(document.querySelector('#Esito_IDStato_t_Img')))
setTimeout(function () {
waitForElementToDisplay(('#tbody_Esito_IDStato > tr:nth-child(16) > td:nth-child(2)'), simulateMouseClick(document.querySelector('#tbody_Esito_IDStato > tr:nth-child(16) > td:nth-child(2)')))
waitForElementToDisplay(('#Esito_MotivoRifiuto_t'), simulateMouseClick(document.querySelector('#Esito_ConfermaEsito_span')))
}, 4000)
}
}
function koirreperibile () {
if (document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item') != null) {
document.querySelector('#MM_Hang').click()
waitForElementToDisplay(('#Esito_IDStato_t'), simulateMouseClick(document.querySelector('#Esito_IDStato_t_Img')))
setTimeout(function () {
waitForElementToDisplay(('#tbody_Esito_IDStato > tr:nth-child(22) > td:nth-child(2)'), simulateMouseClick(document.querySelector('#tbody_Esito_IDStato > tr:nth-child(22) > td:nth-child(2)')))
waitForElementToDisplay(('#Esito_MotivoRifiuto_t'), simulateMouseClick(document.querySelector('#Esito_ConfermaEsito_span')))
}, 4000)
} else {
document.querySelector('#MM_step_row_Esito > td.MM_step_summary_item').click()
document.querySelector('#MM_Hang').click()
waitForElementToDisplay(('#Esito_IDStato_t'), simulateMouseClick(document.querySelector('#Esito_IDStato_t_Img')))
setTimeout(function () {
waitForElementToDisplay(('#tbody_Esito_IDStato > tr:nth-child(22) > td:nth-child(2)'), simulateMouseClick(document.querySelector('#tbody_Esito_IDStato > tr:nth-child(22) > td:nth-child(2)')))
waitForElementToDisplay(('#Esito_MotivoRifiuto_t'), simulateMouseClick(document.querySelector('#Esito_ConfermaEsito_span')))
}, 4000)
}
}
document.onkeyup = function (e) {
switch (true) {
case (e.ctrlKey && e.which === 96):
wip()
break
case (e.ctrlKey && e.which === 97):
cliente()
break
case (e.ctrlKey && e.which === 98):
rifiuto()
break
case (e.ctrlKey && e.which === 99):
cambiocliente()
break
case (e.ctrlKey && e.which === 100):
noretefissa()
break
case (e.ctrlKey && e.which === 101):
koirreperibile()
}
}