Skip to content

Instantly share code, notes, and snippets.

@theY4Kman
Last active August 11, 2017 13:13
Show Gist options
  • Select an option

  • Save theY4Kman/9653078 to your computer and use it in GitHub Desktop.

Select an option

Save theY4Kman/9653078 to your computer and use it in GitHub Desktop.
GreaseMonkey/TamperMonkey userscript to show recent tickets on the Ubersmith view ticket page
// ==UserScript==
// @name Show Client's Recent Tickets
// @version 0.2
// @description List recent tickets of clients directly on the ticket view page
// @match https://manage.hivelocity.net/admin/supportmgr/ticket_view.php*
// @downloadURL https://gist.githubusercontent.com/theY4Kman/9653078/raw/ubersmith_recent_ticekts.tamper.js
// @grant GM_unsafeWindow
// ==/UserScript==
$ = unsafeWindow.$;
$(function() {
var url,
ticket_id,
$recents,
$editform;
url = $('a[href*="ticket_list.php?type=All"]').attr('href');
url += '&listing=activity&order=DESC';
ticket_id = /ticket=(\d+)/.exec($('a[href^="ticket_view.php?ticket="]').attr('href'))[1];
$recents = $('<td></td>');
$editform = $('#editform1');
$('> table > tbody > tr', $editform).append($recents);
$.get(url, function(response) {
var $page,
$table,
$div;
$page = $(response);
$table = $('.table-body', $page);
$table.find('a[href^="?"]').each(function() {
var $this= $(this);
$this.attr('href', 'ticket_list.php' + $this.attr('href') + '&ticket=' + ticket_id);
});
$div = $('<div>Recent tickets:</div>')
$div.css('max-height', $editform.height() + 'px');
$div.css('overflow', 'auto');
$div.append($table);
$recents.append($div);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment