111 lines
4.3 KiB
JavaScript
111 lines
4.3 KiB
JavaScript
// ==UserScript==
|
|
// @name ConnectWiseManageEqualSignRebind
|
|
// @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
|
|
// @grant GM.getClipboard
|
|
// @version 1.0
|
|
// @author -
|
|
// @require https://cdn.jsdelivr.net/npm/@violentmonkey/shortcut@1
|
|
// ==/UserScript==
|
|
VM.shortcut.register('=', () => {
|
|
getTicketInfo();
|
|
copyPodPost(contact+" @ "+company+"\n\n"+detailLabel+"\n\n"+initialDescription+"");
|
|
});
|
|
VM.shortcut.register('a-=', () => {
|
|
getTicketInfo();
|
|
getMoreTicketInfo();
|
|
copyPodPost(contact+" @ "+company+"\n\n"+detailLabel+"\n\n"+initialDescription+"\n\n"+internalNote+"\n\n");
|
|
});
|
|
VM.shortcut.register('c-=', () => {
|
|
getTicketInfo();
|
|
copyPodPost(contact+" @ "+company+"\n\n"+detailLabel+"");
|
|
});
|
|
VM.shortcut.register('c-a-=', () => {
|
|
getTicketInfo();
|
|
copyPodPost(contact+" @ "+company+"\n\n"+detailLabel+"\n\nClient is calling to get in touch with @"+assignedTech+" ");
|
|
});
|
|
|
|
//Functions below
|
|
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);
|
|
contactinput = prompt("What is the caller's name?", contact);
|
|
contact = contactinput;
|
|
company = getByClass('cw_company', 0);
|
|
detailLabel = getInnerTextByClass('detailLabel', 0);
|
|
assignedTech = getByClass('cw_ticketOwner', 0);
|
|
initialDescription = getInnerTextByClass('TicketNote-rowNote', 0);
|
|
};
|
|
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/plain')
|
|
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 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){
|
|
focusClass("cw_status", 0);
|
|
putTextIntoClass("cw_status", 0, desiredStatus);
|
|
} |