diff --git a/Duo Reactivation Ticket Button on Reftool.user.js b/Duo Reactivation Ticket Button on Reftool.user.js new file mode 100644 index 0000000..5013d98 --- /dev/null +++ b/Duo Reactivation Ticket Button on Reftool.user.js @@ -0,0 +1,104 @@ +// ==UserScript== +// @name Duo Reactivation Ticket Button on Reftool +// @namespace http://tampermonkey.net/ +// @version 2.0.1 +// @description Adds a button to create a new duo reactivation ticket with the appropriate fields filled out +// @author Zachary Morello +// @match https://tools.is.oregonstate.edu/reftool2/* +// @include https://tools.is.oregonstate.edu/reftool2/* +// @match https://oregonstate.teamdynamix.com/TDNext/Apps/425/Tickets/New?formId=39063&RequestorUID=de751dc3-eeb7-e611-80cd-000d3a13db68&/duo-reactivation +// @include https://oregonstate.teamdynamix.com/TDNext/Apps/425/Tickets/New?formId=39063* +// @grant none +// ==/UserScript== + +var UID = "de751dc3-eeb7-e611-80cd-000d3a13db68"; +var URL = window.location.href; + + +if(URL.indexOf("tools.is.oregonstate.edu/reftool2/") >=0){ + try{ + window.setTimeout(put_button, 1500); + } + catch(TypeError){ + window.setTimeout(put_button, 1500); + } + +} +else if(URL.indexOf("&/duo-reactivation") >=0){ + window.setTimeout(fill_form_duo_reactivation, 500); +} +//Search for UID every 0.5 seconds +setInterval(ScanForUID,50); + +/* +***Finds the User ID for the currently searched person +*/ +function ScanForUID(){ + if(document.getElementById("account-details") != null) { + var open_tickets = document.getElementById("goto-tickets"); + var parent = open_tickets.parentNode; + var href = parent.children[2].href; + console.log("UID = ",href.split("UID=")[1]); + UID = href.split("UID=")[1]; + + } +} + + + +function fill_form_duo_reactivation(){ + var status = document.getElementById("attribute1306"); + status = status.children; + for(var i=0; i=0){ + try{ + window.setTimeout(put_button, 1500); + } + catch(TypeError){ + window.setTimeout(put_button, 1500); + } + +} +else if(URL.indexOf("&/exchange-migration-help") >=0){ + window.setTimeout(fill_ticket_forms, 500); +} +//Search for UID every 0.5 seconds +setInterval(ScanForUID,50); + +/* +***Finds the User ID for the currently searched person +*/ +function ScanForUID(){ + if(document.getElementById("account-details") != null) { + var open_tickets = document.getElementById("goto-tickets"); + var parent = open_tickets.parentNode; + var href = parent.children[2].href; + console.log("UID = ",href.split("UID=")[1]); + UID = href.split("UID=")[1]; + + } +} +/* +Sets the support item checkbox value to true +Attribute and choice are found by inspecting the element of the ticket creation page. +Take note that some creation pages have differant service offering lists, like Duo and Device/Application Support +*/ +function set_support_item(attribute,choice){ + var exchangesupportitem = document.getElementById("attribute"+ attribute + "Choice"+ choice); + //It's hard to tell which one of these operations actually does what I need it to do so I did all of them at once + exchangesupportitem.value = "true"; + //Support item is still valid but to prevent confusion I set it to be visually checked + exchangesupportitem.checked =true; + //call the "onclick" function for the element manually + var click = exchangesupportitem["onclick"]; + click.call(exchangesupportitem); +} + +//You can find a formID by going to the IT tab and looking at the differant urls that open when you open the "+New" dropdown menu +function fill_ticket_forms(){ + var status = document.getElementById("attribute1306"); //closed + status = status.children; + for(var i=0; i=0){ - window.setTimeout(put_button, 750); + window.setTimeout(put_button, 1500); } else if(URL.indexOf("&/phonelog") >=0){ window.setTimeout(fill_form_generic, 500); @@ -39,6 +39,15 @@ function fill_form_transcripts(){ title.value = "Transcripts Request"; var body = document.getElementById("attribute2937"); body.innerText = "Someone called asking about transcripts. They are a previous student and forgot their ID number. We referred them to the Office of the Registrar."; + var othersupportitem = document.getElementById("attribute38159Choice90187"); + //It's hard to tell which one of these operations actually does what I need it to do so I did all of them at once + othersupportitem.value = "true"; + //Support item is still valid but to prevent confusion I set it to be visually checked + othersupportitem.checked =true; + //call the "onclick" function for the element manually + var click = othersupportitem["onclick"]; + click.call(othersupportitem); + } function fill_form_generic(){ @@ -55,6 +64,8 @@ function fill_form_generic(){ by = by.children; by[0].setAttribute("value", "793"); by[0].innerText = "Phone"; + + } function put_button(){ @@ -99,3 +110,4 @@ function put_button(){ window.open(url, '_blank'); } } + diff --git a/README.md b/README.md index f46ee02..7397fb0 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# TD-Scripts created by Luke Miletta and Tyler Farnham +# TD-Scripts created by Luke Miletta, Tyler Farnham and Zachary Morello