PowerPanel Toolkit

PowerPanel Toolkit

// ==UserScript==
// @name PowerPanel Toolkit
// @namespace http://rsmiley.org/
// @version 1.5
// @description Because Flash sucks.
// @author RogerSmiley|SeanWa
// @include https://secure1.inmotionhosting.com/*
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @grant GM_setClipboard
// ==/UserScript==

jQuery(function($){
  $('.account_container').each(function(){

    // Variables / Used Data
    var username = $(this).find(".acct_username").text();
    var server = $(this).find(".acct_server").text();
    var domain = $(this).find(".acct_domain").text();
    var adminUser = $("textarea[name=hiddenAdmin]").val();
    var pplink = $(location).attr('href');
    var isIMH = false;
    $('.panel-body img').each(function(){
    if(this.src.indexOf('imh_logo_thumb') != -1){
      isIMH = true;
      return;
    }
  });

// Copy T2
$(this).find(".copyFull").empty();
$(this).find(".copyFull").html("T2 Escalation (JS)");
var T2EscData = "*T2C Escalation\nServer: " + server + "\nUser: " + username + "\nDomain Name: " + domain + "\nAffected URL: \n\nAgent: " + adminUser + "\nTier 2C Esclation Point:\nPP Link: " + pplink + "\nVerified: \nEmergency: \n\nIssue or Request: \nTroubleshooting:";
$(this).find(".copyFull").click ( function () {
GM_setClipboard(T2EscData);
} );

//Copy SRT
$(this).find(".copyRevTemp").empty();
$(this).find(".copyRevTemp").html("Copy ServReviewTemp (JS)");
var ServReviewData = "SERVER REVIEW\nServer: " + server + "\nUser: " + username + "\nDomain Name: " + domain + "\nAffected URL: \n\nAgent: " + adminUser + "\nPP Link: " + pplink + "\nVerified: \nEmergency: \n\nIssue or Request: \nCheck Software:\nShellScan:\nGT Metrix:";
$(this).find(".copyRevTemp").click ( function () {
GM_setClipboard(ServReviewData);
} );

// Copy T1 Assign
$(this).find(".copyT2info").empty();
$(this).find(".copyT2info").html("T1 Assign (JS)");
var t1Esc = "***AGENT: " + adminUser + "\nQuick Copy: " + username + " / " + server + " / " + domain + "\nAffected URL: " + domain + "\nPP Link: " + pplink + "\nVerified: Y/N\nIssue or Request:\nTroubleshooting:\n";
$(this).find(".copyT2info").click ( function () {
GM_setClipboard(t1Esc);
} );

// Get rid of the Copy Full button, we don't need that in our lives.
//$(this).find(".copyFull").remove(); // Undid to allow for T1 Assign Button.
$(this).find("#addNote").remove();
$(this).find(".verify").remove();
$(this).find(".escalate").remove();

var toolsPane = $(this).find('.acct_tools')[0];
var controlPane = $(this).find('#quick-controls')[0];

//copy ssh button
var sshCommand = 'ssh ' + server;
if(server.startsWith('vps') || server.startsWith('elite')) sshCommand = 't1ssh ' + server;
var sshCopy = document.createElement('button');
$(sshCopy).text('Copy SSH');
$(sshCopy).click ( function () {
GM_setClipboard(sshCommand);
} );
controlPane.appendChild(sshCopy);

//copy switch button
var switchCopy = document.createElement('button');
$(switchCopy).text('Copy Switch');
$(switchCopy).click ( function () {
GM_setClipboard("switch " + username);
} );
controlPane.appendChild(switchCopy);

//cp jump pane
var cpJumpPane = document.createElement('iframe');
cpJumpPane.name = 'cp_jump_frame';
cpJumpPane.style.border = 'none';
$(cpJumpPane).width(0).height(0);
toolsPane.appendChild(cpJumpPane);

//cPanel
var cPanelLi = document.createElement('li');
$(cPanelLi).html('\
<form method="POST" action="https://cpjump.inmotionhosting.com/cplogin/" target="cp_jump_frame">\
<input name="server" type="hidden" value="' + server + '">\
<input name="username" type="hidden" value= "' + username + '">\
<input name="service" value="cpaneld" type="hidden">\
<button type="submit">cPanel</button>\
</form>\
');
toolsPane.appendChild(cPanelLi);

//IMH-WHM
if(isIMH){
var cPanelLi = document.createElement('li');
$(cPanelLi).html('\
<form method="POST" action="https://cpjump.inmotionhosting.com/cplogin/" target="cp_jump_frame">\
<input name="server" type="hidden" value="' + server + '">\
<input name="username" type="hidden" value= "inmotion">\
<input name="service" value="whostmgrd" type="hidden">\
<button type="submit">IMH-WHM</button>\
</form>\
');
toolsPane.appendChild(cPanelLi);
}else{
var cPanelLi = document.createElement('li');
$(cPanelLi).html('\
<form method="POST" action="https://cpjump.inmotionhosting.com/cplogin/" target="cp_jump_frame">\
<input name="server" type="hidden" value="' + server + '">\
<input name="username" type="hidden" value= "hubhost">\
<input name="service" value="whostmgrd" type="hidden">\
<button type="submit">WHH-WHM</button>\
</form>\
');
toolsPane.appendChild(cPanelLi);
}

//WHM
var cPanelLi = document.createElement('li');
$(cPanelLi).html('\
<form method="POST" action="https://cpjump.inmotionhosting.com/cplogin/" target="cp_jump_frame">\
<input name="server" type="hidden" value="' + server + '">\
<input name="username" type="hidden" value= "' + username + '">\
<input name="service" value="whostmgrd" type="hidden">\
<button type="submit">WHM</button>\
</form>\
');
toolsPane.appendChild(cPanelLi);

//remove broken cPanel and WHM links
$('a[title=WHM]').parent().remove();
$('a[title=cPanel]').parent().remove();

cPanelLi.style.marginLeft = "-10px";

});

//set Method dropdown box when you put the contact type in the text field
$('#comment').bind('input propertychange', function() {
var noteText = this.value.substr(0,9).toLowerCase();

var index = noteText.indexOf(':');
if(noteText.startsWith('chat:')){
$($('#method').children()[3]).prop('selected', true);
}else if(noteText.startsWith('call:')){
$($('#method').children()[2]).prop('selected', true);
}else if(index > 3 && !isNaN(Number(noteText.substr(0,index))) ){
$($('#method').children()[9]).prop('selected', true);
}
});

});