-
Notifications
You must be signed in to change notification settings - Fork 1
/
rtpup.ts
543 lines (516 loc) · 25.1 KB
/
rtpup.ts
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
import * as reg from './regexConstants'
import puppeteer = require('puppeteer')
import { Page } from 'puppeteer'
import { readFileSync } from 'fs'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs')
const pw = readFileSync('./password.txt', 'utf-8')
const login = 'aigibson'
const reedLoginURL = 'https://weblogin.reed.edu/?cosign-help&'
//make sure u edit search to show unlimited rows, not just 50
const searchURL =
'https://help.reed.edu/Search/Results.html?Format=%27%3Cb%3E%3Ca%20href%3D%22__WebPath__%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__id__%3C%2Fa%3E%3C%2Fb%3E%2FTITLE%3A%23%27%2C%0A%27%3Cb%3E%3Ca%20href%3D%22__WebPath__%2FTicket%2FDisplay.html%3Fid%3D__id__%22%3E__Subject__%3C%2Fa%3E%3C%2Fb%3E%2FTITLE%3ASubject%27%2C%0AStatus%2C%0AQueueName%2C%0AOwner%2C%0APriority%2C%0A%27__NEWLINE__%27%2C%0A%27__NBSP__%27%2C%0A%27%3Csmall%3E__Requestors__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__CreatedRelative__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__ToldRelative__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__LastUpdatedRelative__%3C%2Fsmall%3E%27%2C%0A%27%3Csmall%3E__TimeLeft__%3C%2Fsmall%3E%27&Order=ASC%7CASC%7CASC%7CASC&OrderBy=id%7C%7C%7C&Query=(%20Queue%20%3D%20%27cus%27%20OR%20Queue%20%3D%20%27twatch%27%20)%20AND%20Created%20%3C%20%272022-01-01%27%20AND%20Created%20%3E%20%272021-07-31%27%20AND%20%27CF.%7BSupport%20Tags%7D%27%20IS%20NULL%20AND%20id%20%3E%20332850&RowsPerPage=0&SavedChartSearchId=new&SavedSearchId=new'
async function run(currentTicket) {
const ticketURL = 'https://help.reed.edu/Ticket/Display.html?id='
const browser = await puppeteer.launch({
//devtools: true, //this also forces {headless: false}
//dumpio: true //captures all console messages to output https://stackoverflow.com/questions/47539043/how-to-get-all-console-messages-with-puppeteer-including-errors-csp-violations
})
//const page = await browser.newPage()
const [page] = await browser.pages() //this fixes extra empty tab being open instead of above line
//await page.setViewport({ width: 1692, height: 777 }) //({ width: 850, height: 800}); //doesn't matter
await page.goto(reedLoginURL + ticketURL + currentTicket)
await page.type('[name="login"]', login)
await page.type('[name="password"]', pw)
await page.click(`button[class="btn btn-primary pull-right"]`)
await ticketFix(page, currentTicket)
await browser.close()
}
async function checkSpecificBox(page: Page, checkBoxSelector: string): Promise<void> {
//required, otherwise will attempt to click too soon and throw error
await page.waitForSelector(`input[value="${checkBoxSelector}"]`)
// @ts-ignore
await page.$eval(`input[value="${checkBoxSelector}"]`, (check) => (check.checked = true))
// old inefficient way, leaving so my future self can see
//if checkbox is already checked, don't click!
//const checkbox = await page.$(`input[value="google drive"]`);
//let checked = await (await checkbox.getProperty('checked')).jsonValue(); //true if checked, false if unchecked
//if (!checked){
//await checkbox.click();//}
//await page.click(`input[value="google drive"]`);//}
// instead of checking if checked, then clicking, I can directly set checked to true
//await page.$eval(`input[value="google drive"]`, check => check.checked = true);
}
async function ticketFix(page: Page, currentTicket): Promise<void> {
//click "Show all quoted text" anchor; necessary if the init ticket has "show quoted text" and we need it like here https://help.reed.edu/Ticket/Display.html?id=346157
const quotedTextSelector = `#ticket-${currentTicket}-history > div > div.titlebox-title > span.right > a:nth-child(1)`
await page.waitForSelector(quotedTextSelector)
await page.click(quotedTextSelector)
//TITLE EMERITUS SECTION
let emeritus = false
//it's possible there's no title field if there are no requestors
try {
const titleSelector = `.CustomField__Title_ > span.value` //must check if there are multiple
await page.waitForSelector(titleSelector) //this waits for FIRST selector matching, what if the first loads faster than the second??
//this was from when I didn't realize there could b mult requestors
//let titleElement = await page.$(titleSelector);
//let titleValue = await page.evaluate(el => el.textContent, titleElement);
const titleElements = await page.$$(titleSelector)
for await (const titleElement of titleElements) {
const titleValue = await page.evaluate((el) => el.textContent, titleElement)
if (titleValue.includes('emeritus') || titleValue.includes('Emeritus') || titleValue.includes('emerita') || titleValue.includes('Emerita')) {
emeritus = true
}
}
} catch (error) {
console.error(error)
}
//console.log("Emeritus: "+emeritus);
//AFFILIATIONS SECTION
//const affiliationSelector = `.CustomField__Secondary_Affiliations_ > span.value`;
const affiliationSelector = `.CustomField__Primary_Affiliation_ > span.value`
//let affiliationsElement = await page.$(affiliationSelector);
//let affiliationsValue = await page.evaluate(el => el.textContent, affiliationsElement);
let faculty = false
let student = false
let affiliate = false
let alumni = false
let staff = false
const affiliationsElements = await page.$$(affiliationSelector)
for await (const affiliationsElement of affiliationsElements) {
const affiliationsValue = await page.evaluate((el) => el.textContent, affiliationsElement)
if (affiliationsValue.includes('faculty')) {
faculty = true
} else if (affiliationsValue.includes('student')) {
student = true
} else if (affiliationsValue.includes('affiliate')) {
affiliate = true
} else if (affiliationsValue.includes('alumni') || affiliationsValue.includes('alum')) {
alumni = true
} else if (affiliationsValue.includes('staff')) {
staff = true
}
}
// console.log("Faculty: "+faculty);
// console.log("Student: "+student);
// console.log("Affiliate: "+affiliate);
// console.log("Alumni: "+alumni);
//console.log('Staff: ' + staff)
//EMAIL CHECK SECTION
let nonReedEmail = false
const emailSelector = `.EmailAddress > span.value`
const emailElements = await page.$$(emailSelector)
const emails: string[] = []
for await (const emailElement of emailElements) {
const emailValue = await page.evaluate((el) => el.textContent, emailElement)
emails.push(emailValue)
}
if (!emeritus && !student && !affiliate && !alumni && !staff && !faculty && !emails.toString().includes('@reed.edu')) {
nonReedEmail = true
}
// END AFFILIATION, BEGIN SUPPORT TAGS
//the bools which actually decide
let googleDrive = false
let googleGroup = false
let hardware = false
let libraryRelated = false
let massEmail = false
let microsoft = false
let network = false
let passwordReset = false
let phish = false
let printing = false
let reedAccounts = false
let software = false
let thesis = false
let twoFactor = false
let nameChange = false
let virusMalware = false
let noTag = false
let messages = '' //all emails in this string
const ticketHistorySelector = `div.history-container > div.message` //only add it if it's a comment, correspondance, or the initial ticket opening. we don't want others, esp "Support Tags xyz deleted" which could falsely re-trigger the regex for that tag. message class is only transaction we're interested in
await page.waitForSelector(ticketHistorySelector)
const emailStanzas = await page.$$(ticketHistorySelector)
for await (const emailStanza of emailStanzas) {
const emailValue = await page.evaluate((el) => el.innerText, emailStanza) //this gives proper spacing after changing textContent to innerText
messages += emailValue + '\n'
}
messages = messages.replace(reg.cusAutoReplyRegex, '')
messages += emails + '\n' //putting the email values in messages to simplify search
await page.waitForSelector('#header > h1') //title of ticket
const ticketTitleElement = await page.$('#header > h1')
const ticketTitleValue = await page.evaluate((el) => el.textContent, ticketTitleElement)
messages += ticketTitleValue + '\n'
//console.log(messages)
//HARD RULES SECTION (obvious/easy support tag selection). true no matter WHAT. nothing fuzzy/ambiguous.
if (emails.toString().includes('malwarebytes.com')) {
virusMalware = true
} else if (emails.toString().includes('crowdstrike')) {
virusMalware = true
} else if (emails.toString().includes('[email protected]')) {
noTag = true
} //no tag, this is the "Notification of Staff Hire" emails
else if (ticketTitleValue.includes('Welcome to Reed College | Notes for your first day of work')) {
noTag = true
} //no tag https://help.reed.edu/Ticket/Display.html?id=347871
else if (ticketTitleValue.includes('Welcome to Reed College')) {
noTag = true
} //no tag
else if (emails.toString().includes('[email protected]') || ticketTitleValue.includes('groups.reed.edu admins: Message Pending')) {
massEmail = true
} else if (ticketTitleValue.includes('Shared Drive Request')) {
googleDrive = true
} else if (ticketTitleValue.includes('Google Group Request')) {
googleGroup = true
} else if (ticketTitleValue.includes('[Ask a librarian]')) {
libraryRelated = true
} else if (emails.toString().includes('[email protected]')) {
libraryRelated = true
} else if (emails.toString().includes('[email protected]')) {
microsoft = true
passwordReset = true
} else if (emails.toString().includes('@microsoft.com')) {
microsoft = true
} else if (emails.toString().includes('@microsoftonline.com')) {
microsoft = true
} else if (ticketTitleValue.includes('Wireless Maintenance')) {
network = true
} else if (ticketTitleValue.includes('ipp.reed.edu')) {
network = true
printing = true
} else if (ticketTitleValue.includes('Kerberos password reset')) {
passwordReset = true
} //https://help.reed.edu/Ticket/Display.html?id=344626
else if (emails.toString().includes('[email protected]')) {
phish = true
} else if (emails.toString().includes('xerox') || emails.toString().includes('ctx')) {
printing = true
} else if (ticketTitleValue.includes('Reed computing account')) {
reedAccounts = true
} else if (ticketTitleValue.includes('Your Reed computing accounts are scheduled to be closed')) {
reedAccounts = true
} else if (messages.includes('Please follow the steps below to setup your Reed account')) {
reedAccounts = true
} else if (ticketTitleValue.includes('Account Closure for Graduates')) {
reedAccounts = true
} else if (ticketTitleValue.includes('Account Tool')) {
reedAccounts = true
} else if (ticketTitleValue.includes('Computing at Reed')) {
reedAccounts = true
} else if (ticketTitleValue.includes('Duo') || ticketTitleValue.includes('DUO') || ticketTitleValue.includes('duo')) {
twoFactor = true
} else if (emails.toString().includes('schrodinger.com')) {
noTag = true
} else if (ticketTitleValue.includes('google group')) {
googleGroup = true
} else if (ticketTitleValue.includes('Google Group')) {
googleGroup = true
} else if (emails.toString().includes('[email protected]')) {
reedAccounts = true
} else if (ticketTitleValue.includes('CUS Computer Maintenance Required') || ticketTitleValue.includes('Tracking Down') || ticketTitleValue.includes('tracking down')) {
hardware = true
} else if (messages.includes('Code42')) {
software = true
} else {
//regex section, only run if no hard rules found (moved regex lists outside of fnc to b global
//maybe score it??? +1 point for each regex hit, -1 point for each NOhit? BUT there can b mult tags...tricky
const googleDriveMatch = reg.googleDriveRegexList.some((rx) => rx.test(messages)) && !reg.noGoogleDriveRegexList.some((rx) => rx.test(messages))
const googleGroupMatch = reg.googleGroupRegexList.some((rx) => rx.test(messages)) && !reg.noGoogleGroupRegexList.some((rx) => rx.test(messages))
const hardwareMatch = reg.hardwareRegexList.some((rx) => rx.test(messages)) && !reg.noHardwareRegexList.some((rx) => rx.test(messages))
const libraryRelatedMatch = reg.libraryRelatedRegexList.some((rx) => rx.test(messages)) && !reg.noLibraryRelatedRegexList.some((rx) => rx.test(messages))
const massEmailMatch = reg.massEmailRegexList.some((rx) => rx.test(messages)) && !reg.noMassEmailRegexList.some((rx) => rx.test(messages))
const microsoftMatch = reg.microsoftRegexList.some((rx) => rx.test(messages)) && !reg.noMicrosoftRegexList.some((rx) => rx.test(messages))
const networkMatch = reg.networkRegexList.some((rx) => rx.test(messages)) && !reg.noNetworkRegexList.some((rx) => rx.test(messages))
const passwordResetMatch = reg.passwordResetRegexList.some((rx) => rx.test(messages)) && !reg.noPasswordResetRegexList.some((rx) => rx.test(messages))
const phishMatch = reg.phishRegexList.some((rx) => rx.test(messages)) && !reg.noPhishRegexList.some((rx) => rx.test(messages))
const printingMatch = reg.printingRegexList.some((rx) => rx.test(messages)) && !reg.noPrintingRegexList.some((rx) => rx.test(messages))
const reedAccountsMatch = reg.reedAccountsRegexList.some((rx) => rx.test(messages)) && !reg.noReedAccountsRegexList.some((rx) => rx.test(messages))
const softwareMatch = reg.softwareRegexList.some((rx) => rx.test(messages)) && !reg.noSoftwareRegexList.some((rx) => rx.test(messages))
const thesisMatch = reg.thesisRegexList.some((rx) => rx.test(messages)) && !reg.noThesisRegexList.some((rx) => rx.test(messages))
const twoFactorMatch = reg.twoFactorRegexList.some((rx) => rx.test(messages)) && !reg.noTwoFactorRegexList.some((rx) => rx.test(messages))
const nameChangeMatch = reg.nameChangeRegexList.some((rx) => rx.test(messages)) && !reg.noNameChangeRegexList.some((rx) => rx.test(messages))
const virusMalwareMatch = reg.virusMalwareRegexList.some((rx) => rx.test(messages)) && !reg.noVirusMalwareRegexList.some((rx) => rx.test(messages))
const noTagMatch = reg.noTagRegexList.some((rx) => rx.test(messages)) && !reg.noNoTagRegexList.some((rx) => rx.test(messages))
//logic of Match bools -> real bools
//this may seem redundant to have the "match" set of bools as well, but it gives extra flexibility
if (noTagMatch && !massEmailMatch) {
noTag = true
} else {
if (googleDriveMatch) {
googleDrive = true
}
if (googleGroupMatch) {
googleGroup = true
}
if (hardwareMatch) {
hardware = true
}
if (libraryRelatedMatch) {
libraryRelated = true
}
if (massEmailMatch) {
massEmail = true
}
if (microsoftMatch) {
microsoft = true
}
if (networkMatch) {
network = true
}
if (phishMatch) {
phish = true
}
if (printingMatch) {
printing = true
}
if (reedAccountsMatch) {
reedAccounts = true
}
if (softwareMatch) {
software = true
}
if (twoFactorMatch) {
twoFactor = true
}
if (nameChangeMatch) {
nameChange = true
}
if (virusMalwareMatch) {
virusMalware = true
}
//keep these exceptions at bottom
if (passwordResetMatch) {
passwordReset = true
reedAccounts = false
} //if password reset, NOT reed account, always
if (thesisMatch) {
thesis = true
microsoft = false
} //if thesis, NOT microsoft, always
if (noTag && massEmail) {
massEmail = true
noTag = false
}
}
//if no matches (no regex match AND no hard rule match(implied here)), flag for manual review
if (!googleDriveMatch && !googleGroupMatch && !hardwareMatch && !libraryRelatedMatch && !massEmailMatch && !microsoftMatch && !networkMatch && !passwordResetMatch && !phishMatch && !printingMatch && !reedAccountsMatch && !softwareMatch && !thesisMatch && !twoFactorMatch && !nameChangeMatch && !virusMalwareMatch && !noTagMatch && !noTag) {
console.log('FLAG NO REGEX MATCH ' + page.url())
fs.appendFile('lucas.txt', page.url() + '\n', (err: any) => {
if (err) throw err
})
}
} //end of else regex section
// console.log('Current Ticket: ' + page.url())
//PAGE CHANGE
const currURL: string = page.url()
//replace Display with Modify
const modifyURL: string = currURL.replace('Display', 'Modify')
await page.goto(modifyURL)
//checks if in t-watch or cus queue; other queues will probably MOSTLY work but I haven't tested so I'm excluding
const queue = await page.$$(`select.select-queue`)
const queueValue = await page.evaluate((q) => q.value, queue[1])
if (queueValue != 4 && queueValue != 11) {
console.log('Not CUS or TWatch Queue' + ' ' + queueValue)
process.exit() //ends entire script
}
//comparison code; no longer needed
// const googleDriveCheckbox = await page.$(`input[value="google drive"]`)
// const googleDriveChecked = await (await googleDriveCheckbox.getProperty('checked')).jsonValue()
// if (googleDrive != googleDriveChecked) {
// console.log('Algo Google Drive: ' + googleDrive + 'Ticket Google Drive: ' + googleDriveChecked)
// }
//
// const googleGroupCheckbox = await page.$(`input[value="google group"]`)
// const googleGroupChecked = await (await googleGroupCheckbox.getProperty('checked')).jsonValue()
// if (googleGroup != googleGroupChecked) {
// console.log('Algo Google Group: ' + googleGroup + 'Ticket Google Group: ' + googleGroupChecked)
// }
//
// const hardwareCheckbox = await page.$(`input[value="hardware"]`)
// const hardwareChecked = await (await hardwareCheckbox.getProperty('checked')).jsonValue()
// if (hardware != hardwareChecked) {
// console.log('Algo Hardware: ' + hardware + 'Ticket Hardware: ' + hardwareChecked)
// }
//
// const libraryRelatedCheckbox = await page.$(`input[value="library related"]`)
// const libraryRelatedChecked = await (await libraryRelatedCheckbox.getProperty('checked')).jsonValue()
// if (libraryRelated != libraryRelatedChecked) {
// console.log('Algo LibraryRelated: ' + libraryRelated + 'Ticket LibraryRelated: ' + libraryRelatedChecked)
// }
//
// const massEmailCheckbox = await page.$(`input[value="mass email"]`)
// const massEmailChecked = await (await massEmailCheckbox.getProperty('checked')).jsonValue()
// if (massEmail != massEmailChecked) {
// console.log('Algo massEmail: ' + massEmail + 'Ticket massEmail: ' + massEmailChecked)
// }
//
// const microsoftCheckbox = await page.$(`input[value="microsoft"]`)
// const microsoftChecked = await (await microsoftCheckbox.getProperty('checked')).jsonValue()
// if (microsoft != microsoftChecked) {
// console.log('Algo microsoft: ' + microsoft + 'Ticket microsoft: ' + microsoftChecked)
// for (let i = 0; i < reg.microsoftRegexList.length; i++) {
// console.log(reg.microsoftRegexList[i].exec(messages))
// }
// }
//
// const networkCheckbox = await page.$(`input[value="network"]`)
// const networkChecked = await (await networkCheckbox.getProperty('checked')).jsonValue()
// if (network != networkChecked) {
// console.log('Algo network: ' + network + 'Ticket network: ' + networkChecked)
// }
//
// const passwordResetCheckbox = await page.$(`input[value="password reset"]`)
// const passwordResetChecked = await (await passwordResetCheckbox.getProperty('checked')).jsonValue()
// if (passwordReset != passwordResetChecked) {
// console.log('Algo passwordReset: ' + passwordReset + 'Ticket passwordReset: ' + passwordResetChecked)
// }
//
// const phishCheckbox = await page.$(`input[value="phish report/fwd"]`)
// const phishChecked = await (await phishCheckbox.getProperty('checked')).jsonValue()
// if (phish != phishChecked) {
// console.log('Algo phish: ' + phish + 'Ticket phish: ' + phishChecked)
// }
//
// const printingCheckbox = await page.$(`input[value="printers/copiers"]`)
// const printingChecked = await (await printingCheckbox.getProperty('checked')).jsonValue()
// if (printing != printingChecked) {
// console.log('Algo printing: ' + printing + 'Ticket printing: ' + printingChecked)
// }
//
// const reedAccountsCheckbox = await page.$(`input[value="reed accounts & access"]`)
// const reedAccountsChecked = await (await reedAccountsCheckbox.getProperty('checked')).jsonValue()
// if (reedAccounts != reedAccountsChecked) {
// console.log('Algo reedAccounts: ' + reedAccounts + 'Ticket reedAccounts: ' + reedAccountsChecked)
// }
//
// const softwareCheckbox = await page.$(`input[value="software"]`)
// const softwareChecked = await (await softwareCheckbox.getProperty('checked')).jsonValue()
// if (software != softwareChecked) {
// console.log('Algo software: ' + software + 'Ticket software: ' + softwareChecked)
// for (let i = 0; i < reg.softwareRegexList.length; i++) {
// console.log(reg.softwareRegexList[i].exec(messages))
// }
// }
//
// const thesisCheckbox = await page.$(`input[value="thesis"]`)
// const thesisChecked = await (await thesisCheckbox.getProperty('checked')).jsonValue()
// if (thesis != thesisChecked) {
// console.log('Algo thesis: ' + thesis + 'Ticket thesis: ' + thesisChecked)
// }
//
// const twoFactorCheckbox = await page.$(`input[value="two-factor"]`)
// const twoFactorChecked = await (await twoFactorCheckbox.getProperty('checked')).jsonValue()
// if (twoFactor != twoFactorChecked) {
// console.log('Algo twoFactor: ' + twoFactor + 'Ticket twoFactor: ' + twoFactorChecked)
// }
//
// const nameChangeCheckbox = await page.$(`input[value="user/name change"]`)
// const nameChangeChecked = await (await nameChangeCheckbox.getProperty('checked')).jsonValue()
// if (nameChange != nameChangeChecked) {
// console.log('Algo nameChange: ' + nameChange + 'Ticket nameChange: ' + nameChangeChecked)
// }
//
// const virusMalwareCheckbox = await page.$(`input[value="virus/malware"]`)
// const virusMalwareChecked = await (await virusMalwareCheckbox.getProperty('checked')).jsonValue()
// if (virusMalware != virusMalwareChecked) {
// console.log('Algo virusMalware: ' + virusMalware + 'Ticket virusMalware: ' + virusMalwareChecked)
// }
//console.log('End')
if (!massEmail) {
//don't set affiliation if mass email
if (emeritus) {
if (faculty) {
checkSpecificBox(page, 'emeritus/emerita')
checkSpecificBox(page, 'faculty')
} else if (staff) {
checkSpecificBox(page, 'emeritus/emerita')
checkSpecificBox(page, 'staff')
}
} else if (student) {
checkSpecificBox(page, 'student')
//if(affiliate){checkSpecificBox(page,"affiliate")}
} else if (alumni) {
checkSpecificBox(page, 'alumni')
//if(faculty){checkSpecificBox(page,"faculty")}
//if(staff){checkSpecificBox(page,"staff")}
//if(affiliate){checkSpecificBox(page,"affiliate")}
} else if (faculty) {
checkSpecificBox(page, 'faculty')
} else if (staff) {
checkSpecificBox(page, 'staff')
} else if (affiliate) {
checkSpecificBox(page, 'affiliate')
} else if (nonReedEmail && (ticketTitleValue.includes('applicant') || ticketTitleValue.includes('Applicant'))) {
console.log('FLAG Possible Applicant: ' + modifyURL)
}
}
//SUPPORT TAGS CHECKING BOXES
if (googleDrive) {
checkSpecificBox(page, 'google drive')
}
if (googleGroup) {
checkSpecificBox(page, 'google group')
}
if (hardware) {
checkSpecificBox(page, 'hardware')
}
if (libraryRelated) {
checkSpecificBox(page, 'library related')
}
if (massEmail) {
checkSpecificBox(page, 'mass email')
}
if (microsoft) {
checkSpecificBox(page, 'microsoft')
}
if (network) {
checkSpecificBox(page, 'network')
}
if (passwordReset) {
checkSpecificBox(page, 'password reset')
}
if (phish) {
checkSpecificBox(page, 'phish report/fwd')
}
if (printing) {
checkSpecificBox(page, 'printers/copiers')
}
if (reedAccounts) {
checkSpecificBox(page, 'reed accounts & access')
}
if (software) {
checkSpecificBox(page, 'software')
}
if (thesis) {
checkSpecificBox(page, 'thesis')
}
if (twoFactor) {
checkSpecificBox(page, 'two-factor')
}
if (nameChange) {
checkSpecificBox(page, 'user/name change')
}
if (virusMalware) {
checkSpecificBox(page, 'virus/malware')
}
//presses submit
await page.click('#TicketModify > div.submit > div.buttons > input')
//process.abort() //exit() kills the script too soon, only abort works for some reason!
}
;(async () => {
const browser = await puppeteer.launch({ headless: true })
const [page] = await browser.pages()
await page.goto(reedLoginURL + searchURL)
await page.type('[name="login"]', login)
await page.type('[name="password"]', pw)
await page.click(`button[class="btn btn-primary pull-right"]`)
//wait for page load. (no network requests for idleTime ms, trying to b super generous & borderline inefficient but whatever, this could b used on lots of tickets&a shitty connection
await page.waitForNetworkIdle({ idleTime: 10000 })
const tickets = await page.$$eval(`tbody.list-item`, (el) => el.map((x) => x.getAttribute('data-record-id')))
console.log(tickets.length)
for (const ticket in tickets) {
console.log(tickets[ticket])
await run(tickets[ticket])
}
await browser.close()
})()