393 lines
13 KiB
JavaScript
393 lines
13 KiB
JavaScript
// ==UserScript==
|
|
// @name New script - myconnectwise.net
|
|
// @namespace Violentmonkey Scripts
|
|
// @match https://na.myconnectwise.net/*
|
|
// @match https://app.powerbi.com/*
|
|
// @grant GM.openInTab
|
|
// @grant GM.getValue
|
|
// @grant GM.setValue
|
|
// @grant GM.setClipboard
|
|
// @version 1.0
|
|
// @author -
|
|
// @require https://cdn.jsdelivr.net/npm/@violentmonkey/shortcut@1
|
|
// ==/UserScript==
|
|
|
|
//Declare global variables
|
|
var contact = ""
|
|
var contactinput = ""
|
|
var company = ""
|
|
var detailLabel = ""
|
|
var initialDescription = ""
|
|
var internalNote = ""
|
|
var assignedTech = ""
|
|
var assignedPod = ""
|
|
var ticketlink = ""
|
|
var ticketnumber = ""
|
|
var detailLabelSplit = ""
|
|
var oldTime = ""
|
|
var newTime = ""
|
|
|
|
//Hotkeys
|
|
|
|
|
|
|
|
VM.shortcut.register('c-a-s', () => {
|
|
company = getByClass('cw_company', 0);
|
|
GM.setClipboard("https://hudu.247mgmt.com/c?tab=&page=&sort_direction=&sort_column=&tag=&folder=&query="+company);
|
|
});
|
|
VM.shortcut.register('a-i', () => {
|
|
document.querySelector('[data-id="internal"]').click();
|
|
});
|
|
VM.shortcut.register('a-s-i', () => {
|
|
document.querySelector('[data-id="discussion"]').click();
|
|
});
|
|
VM.shortcut.register('a-r', () => {
|
|
document.querySelector('[data-id="resolution"]').click();
|
|
});
|
|
VM.shortcut.register('a-1', () => {
|
|
setStatus("In Progress")
|
|
});
|
|
VM.shortcut.register('a-s-!', () => {
|
|
setStatus("In Queue")
|
|
});
|
|
VM.shortcut.register('c-s-!', () => {
|
|
setStatus("In Chat")
|
|
});
|
|
VM.shortcut.register('a-2', () => {
|
|
setStatus("New Via Phone")
|
|
});
|
|
VM.shortcut.register('a-s-@', () => {
|
|
setStatus("New Transfer From Triage")
|
|
});
|
|
VM.shortcut.register('a-3', () => {
|
|
setStatus("Pending Tech Assignment")
|
|
});
|
|
VM.shortcut.register('a-s-#', () => {
|
|
setStatus("Agent Responded")
|
|
});
|
|
VM.shortcut.register('a-4', () => {
|
|
setStatus("Completed (Closed)")
|
|
});
|
|
VM.shortcut.register('a-s-$', () => {
|
|
setStatus("Enter Time")
|
|
});
|
|
VM.shortcut.register('a-5', () => {
|
|
setStatus("Waiting on client")
|
|
});
|
|
VM.shortcut.register('a-s-%', () => {
|
|
setStatus("Canceled")
|
|
});
|
|
VM.shortcut.register('a-6', () => {
|
|
setStatus("Scheduled for Remote")
|
|
});
|
|
VM.shortcut.register('a-s-^', () => {
|
|
putTextIntoClass("cw_workType", 0, "Voicemail/Email")
|
|
focusClass("cw_workType", 0)
|
|
focusClass("public-DraftEditor-content", 0)
|
|
});
|
|
VM.shortcut.register('c-a-1', () => {
|
|
document.title="Contact"
|
|
});
|
|
VM.shortcut.register('c-a-2', () => {
|
|
document.title="Companies"
|
|
});
|
|
VM.shortcut.register('c-a-3', () => {
|
|
document.title="In Queue"
|
|
});
|
|
VM.shortcut.register('c-a-4', () => {
|
|
document.title="SLA"
|
|
focusSlaMonitoring();
|
|
});
|
|
VM.shortcut.register('c-a-5', () => {
|
|
document.title="Triage"
|
|
});
|
|
VM.shortcut.register('c-a-6', () => {
|
|
document.title="Ticket Search"
|
|
});
|
|
VM.shortcut.register('c-a-s-W', () => {
|
|
company = getByClass('cw_company', 0);
|
|
GM.setValue('company', company);
|
|
GM.setValue('pod', "");
|
|
});
|
|
VM.shortcut.register('c-a-s-R', () => {
|
|
clickClass("multilineClickable", 1)
|
|
});
|
|
VM.shortcut.register('c-a-s', () => {
|
|
assignedPod = ""
|
|
async function setPod(){
|
|
assignedPod = await GM.getValue("pod", 0);
|
|
await focusClass("cw_serviceBoard", 0);
|
|
await putTextIntoClass("cw_serviceBoard", 0, assignedPod + " - *Support");
|
|
}setPod();
|
|
});
|
|
VM.shortcut.register('a-s-s', () => {
|
|
clickClass("cw_ToolbarButton_Save", 0);
|
|
});
|
|
VM.shortcut.register('m--', () => {
|
|
clickClass("cw-gxt-wnd-cls", 0);
|
|
});
|
|
VM.shortcut.register('a-Delete', () => {
|
|
clickClass("cw-gxt-wnd-cls", 0);
|
|
});
|
|
VM.shortcut.register('a-s-Delete', () => {
|
|
clickClass("cw_CwNegativeActionButton", 0);
|
|
});
|
|
|
|
|
|
//TICKET NOTE SHORTCUTS START
|
|
VM.shortcut.register('a-contextmenu', () => {
|
|
clickClass('TicketNote-newNoteButton', 0);
|
|
});
|
|
VM.shortcut.register('f3', () => {
|
|
clickClass('TicketNote-newNoteButton', 0);
|
|
});
|
|
VM.shortcut.register('s-f3', () => {
|
|
clickClass('cw_isEnteringTime', 0);
|
|
clickClass('DraftEditor-editorContainer', 0);
|
|
});
|
|
VM.shortcut.register('c-f3', () => {
|
|
clickClass('cw_isDiscussion', 0);
|
|
});
|
|
VM.shortcut.register('a-f3', () => {
|
|
clickClass('cw_isInternal', 0);
|
|
});
|
|
VM.shortcut.register('c-a-f3', () => {
|
|
clickClass('cw_isResolution', 0);
|
|
});
|
|
VM.shortcut.register('m-s-f4', () => {
|
|
clickClass('cw_isToContact', 0);
|
|
});
|
|
VM.shortcut.register('c-s-f4', () => {
|
|
clickClass('cw_isToResources', 0);
|
|
});
|
|
VM.shortcut.register('m-f4', () => {
|
|
clickClass('cw_isToCcs', 0);
|
|
});
|
|
VM.shortcut.register('m-[', () => {
|
|
getElementByClass("cw_btnStartTime", 0).children[0].click()
|
|
});
|
|
VM.shortcut.register('m-s-{', () => {
|
|
document.querySelector('[title="Start Time"]').click()
|
|
});
|
|
VM.shortcut.register('m-]', () => {
|
|
getElementByClass("cw_btnEndTime", 0).children[0].click()
|
|
});
|
|
VM.shortcut.register('m-s-}', () => {
|
|
//window.alert(getElementByClass("cw_endTime", 0).value)
|
|
getElementByClass("cw_btnEndTime", 0).children[0].click()
|
|
oldTime = getElementByClass("cw_endTime", 0).value
|
|
let newTime = addMinute(oldTime);
|
|
focusClass("cw_endTime", 0);
|
|
putTextIntoClass("cw_endTime", 0, newTime);
|
|
focusClass("public-DraftEditor-content", 0)
|
|
});
|
|
//TICKET NOTE SHORTCUTS END
|
|
|
|
|
|
|
|
VM.shortcut.register('f10', () => {
|
|
getTicketInfo();
|
|
copyPodPost(contact+" @ "+company+"<br><br>"+detailLabel+"<br><br>"+initialDescription+"<br><br>");
|
|
});
|
|
VM.shortcut.register('a-f10', () => {
|
|
getTicketInfo();
|
|
getMoreTicketInfo();
|
|
copyPodPost(contact+" @ "+company+"<br><br>"+detailLabel+"<br><br>"+initialDescription+"<br><br>"+internalNote+"<br><br>");
|
|
});
|
|
VM.shortcut.register('c-f10', () => {
|
|
getTicketInfo();
|
|
copyPodPost(contact+" @ "+company+"<br><br>"+detailLabel+"<br><br>");
|
|
});
|
|
VM.shortcut.register('c-a-f10', () => {
|
|
getTicketInfo();
|
|
copyPodPost(contact+" @ "+company+"<br><br>"+detailLabel+"<br><br>Client is calling to get in touch with @"+assignedTech+" ");
|
|
});
|
|
VM.shortcut.register('m-f10', () => {
|
|
getTicketInfo();
|
|
copyPodPost(detailLabel);
|
|
});
|
|
VM.shortcut.register('m-s-f10', () => {
|
|
ticketLabel = getInnerTextByClass('detailLabel', 0);
|
|
GM.setClipboard(ticketLabel);
|
|
window.alert("Copied to clipboard: "+ticketLabel);
|
|
});
|
|
VM.shortcut.register('f6', () => {
|
|
clickClass('cw-toolbar-clear', 0);
|
|
clickClass('cw-ml-search-button', 0);
|
|
});
|
|
VM.shortcut.register('s-f6', () => {
|
|
clickClass('cw_ToolbarButton_Refresh', 0);
|
|
});
|
|
VM.shortcut.register('f7', () => {
|
|
clickClass('cw_ToolbarButton_Refresh', 0);
|
|
});
|
|
VM.shortcut.register('c-a-BackSpace', () => {
|
|
clickClass('cw_ToolbarButton_Back', 0);
|
|
clickClass('cw-gxt-wnd-cls', 0);
|
|
});
|
|
VM.shortcut.register('a--', () => {
|
|
clickClass('cw_ToolbarButton_Back', 0);
|
|
clickClass('cw-gxt-wnd-cls', 0);
|
|
});
|
|
VM.shortcut.register('f12', () => {
|
|
doTimeSheet("9:00 AM", "2:30 PM", "Mentoring");
|
|
});
|
|
VM.shortcut.register('a-f12', () => {
|
|
doTimeSheet("3:30 PM", "4:30 PM", "Lunch Break");
|
|
});
|
|
VM.shortcut.register('s-f12', () => {
|
|
doTimeSheet("4:30 PM", "6:00 PM", "Mentoring");
|
|
});
|
|
VM.shortcut.register('c-a-f12', () => {
|
|
doTimeSheetMini("Call Queue");
|
|
});
|
|
|
|
|
|
//PowerBI Script Start
|
|
var pod
|
|
VM.shortcut.register('f2', () => {
|
|
document.querySelector('[aria-label="Navigating to visual"]').focus();
|
|
document.querySelector('[aria-label="enter your search"]').focus();
|
|
});
|
|
VM.shortcut.register('s-f2', () => {
|
|
async function pasteCompany(){
|
|
company = await GM.getValue('company', 0);
|
|
document.querySelector('[aria-label="Enter your search"]').value = company;
|
|
}pasteCompany();
|
|
});
|
|
VM.shortcut.register('c-f2', () => {
|
|
//pod = document.querySelector("#pvExplorationHost > div > div > exploration > div > explore-canvas > div > div.canvasFlexBox > div > div.displayArea.disableAnimations.fitToPage > div.visualContainerHost.visualContainerOutOfFocus > visual-container-repeat > visual-container:nth-child(2) > transform > div > div.visualContent > div > div > visual-modern > div > div > div.pivotTable > div.interactive-grid.innerContainer > div.mid-viewport > div > div:nth-child(1) > div.scrollable-cells-viewport > div > div:nth-child(2)").innerText
|
|
pod = document.querySelector("#pvExplorationHost > div > div > exploration > div > explore-canvas > div > div.canvasFlexBox > div > div.displayArea.disableAnimations.fitToPage > div.visualContainerHost.visualContainerOutOfFocus > visual-container-repeat > visual-container:nth-child(3) > transform > div > div.visualContent > div > div > visual-modern > div > div > div.pivotTable > div.interactive-grid.innerContainer > div.mid-viewport > div > div > div.scrollable-cells-viewport > div > div:nth-child(2)").innerText
|
|
pod = pod.replace(/\u00a0/g, " ");
|
|
podFirst = pod.split(" ")[0];
|
|
podFirstUp = podFirst.toUpperCase();
|
|
GM.setValue('pod', podFirstUp)
|
|
});
|
|
//PowerBI Script END
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Functions
|
|
function addMinute(timeStr) {
|
|
// Parse the time string
|
|
let [time, modifier] = timeStr.split(' ');
|
|
let [hours, minutes] = time.split(':').map(Number);
|
|
|
|
// Add one minute
|
|
minutes += 1;
|
|
|
|
// Handle minute overflow
|
|
if (minutes === 60) {
|
|
minutes = 0;
|
|
hours += 1;
|
|
}
|
|
|
|
// Handle hour overflow and AM/PM switch
|
|
if (hours === 12) {
|
|
modifier = modifier === 'AM' ? 'PM' : 'AM';
|
|
} else if (hours === 13) {
|
|
hours = 1;
|
|
}
|
|
|
|
// Format the new time string
|
|
let newTimeStr = `${hours}:${minutes.toString().padStart(2, '0')} ${modifier}`;
|
|
return newTimeStr;
|
|
}
|
|
function focusSlaMonitoring(){
|
|
putTextIntoClass('cw_CwComboBox', 2, 'Response SLA Monitoring');
|
|
clickClass('cw-ml-search-button', 0);
|
|
}
|
|
async function doTimeSheet(startTime, endTime, chargeTo){
|
|
await putTextIntoClass("cw_ChargeToTextBox", 0, chargeTo);
|
|
await focusClass("cw_startTime", 0);
|
|
await putTextIntoClass("cw_startTime", 0, startTime);
|
|
await focusClass("cw_endTime", 0);
|
|
await putTextIntoClass("cw_endTime", 0, endTime);
|
|
await focusClass("cw_ChargeToTextBox", 0);
|
|
await new Promise(r => setTimeout(r, 800));
|
|
await clickClass("cw_Refresh", 0);
|
|
await new Promise(r => setTimeout(r, 1200));
|
|
await contains("span", chargeTo)[0].click();
|
|
await new Promise(r => setTimeout(r, 500));
|
|
// await clickClass("cw_ToolbarButton_SaveAndClose", 0);
|
|
};
|
|
async function doTimeSheetMini(chargeTo){
|
|
await putTextIntoClass("cw_ChargeToTextBox", 0, chargeTo);
|
|
await focusClass("cw_ChargeToTextBox", 0);
|
|
await new Promise(r => setTimeout(r, 800));
|
|
await clickClass("cw_Refresh", 0);
|
|
await new Promise(r => setTimeout(r, 1200));
|
|
await contains("span", chargeTo)[0].click();
|
|
//await new Promise(r => setTimeout(r, 500));
|
|
//await clickClass("cw_ToolbarButton_SaveAndClose", 0);
|
|
};
|
|
function contains(selector, text) {
|
|
var elements = document.querySelectorAll(selector);
|
|
return Array.prototype.filter.call(elements, function(element){
|
|
return RegExp(text).test(element.textContent);
|
|
});
|
|
}
|
|
function getTicketInfo(){
|
|
contactinput = null;
|
|
document.querySelector('[data-id="internal"]').click(); // click internal note so we can pull it later
|
|
contact = getByClass('cw_contact', 0);
|
|
company = getByClass('cw_company', 0);
|
|
detailLabel = getInnerTextByClass('detailLabel', 0);
|
|
detailLabelSplit = detailLabel.split(" ");
|
|
ticketnumber = detailLabelSplit[2].replace("#", "");
|
|
ticketlink = "<a class='ui-text byt bew bxw byu byv byw' dir='auto' data-nav='true' title='https://na.myconnectwise.net/v4_6_release/services/system_io/router/openrecord.rails?companyName=wheelhouseit&recordType=ServiceFv&recid=TICKETLINKNUMBER' target='_blank' rel='noreferrer noopener' href='https://na.myconnectwise.net/v4_6_release/services/system_io/router/openrecord.rails?companyName=wheelhouseit&recordType=ServiceFv&recid=TICKETLINKNUMBER'>TICKETLINKNUMBER</a>".replace(/TICKETLINKNUMBER/g, ticketnumber);
|
|
detailLabel = detailLabel.replace(ticketnumber,ticketlink);
|
|
assignedTech = getByClass('cw_ticketOwner', 0);
|
|
initialDescription = getInnerTextByClass('TicketNote-rowNote', 0);
|
|
contactinput = prompt("What is the caller's name?", contact);
|
|
contact = contactinput;
|
|
};
|
|
function getMoreTicketInfo(){
|
|
internalNote = getInnerTextByClass('TicketNote-noteLabel', 1);
|
|
};
|
|
function copyPodPost(podPost){
|
|
if (contactinput === null){ //terminate function if user hits cancel button or provides no input
|
|
return;
|
|
}
|
|
GM.setClipboard(podPost, 'text/html')
|
|
window.alert(podPost);
|
|
};
|
|
function clickClass(theClass, elementIndex){
|
|
var elements = document.getElementsByClassName(theClass);
|
|
var requiredElement = elements[elementIndex];
|
|
requiredElement.click();
|
|
};
|
|
function focusClass(theClass, elementIndex){
|
|
var elements = document.getElementsByClassName(theClass);
|
|
var requiredElement = elements[elementIndex];
|
|
requiredElement.focus();
|
|
};
|
|
function getElementByClass(theClass, elementIndex){
|
|
var elements = document.getElementsByClassName(theClass); var requiredElement = elements[elementIndex]; return requiredElement;
|
|
};
|
|
function getByClass(theClass, elementIndex){
|
|
var elements = document.getElementsByClassName(theClass); var requiredElement = elements[elementIndex]; return requiredElement.value;
|
|
};
|
|
function getInnerTextByClass(theClass, elementIndex){
|
|
var elements = document.getElementsByClassName(theClass); var requiredElement = elements[elementIndex]; return requiredElement.innerText;
|
|
};
|
|
function putTextIntoClass(theClass, elementIndex, text){
|
|
var elements = document.getElementsByClassName(theClass); var requiredElement = elements[elementIndex]; requiredElement.value = text;
|
|
};
|
|
function setStatus(desiredStatus){
|
|
if (window.location.href.indexOf("timeexpensemodule.html") > -1) {
|
|
putTextIntoClass("cw_ticketStatus", 0, desiredStatus);
|
|
focusClass("cw_ticketStatus", 0);
|
|
}else{
|
|
putTextIntoClass("cw_status", 0, desiredStatus);
|
|
focusClass("cw_status", 0);
|
|
}
|
|
}
|
|
|
|
|
|
|