Skip to content

Instantly share code, notes, and snippets.

@tresni
Last active January 10, 2016 21:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tresni/5953730 to your computer and use it in GitHub Desktop.
Save tresni/5953730 to your computer and use it in GitHub Desktop.
1.1.0 - Fixed a bug where it would grab all custom apps and not just the ones for this view
// ==UserScript==
// @name Zendesk - Set App Order
// @namespace com.opendns.zendesksetapporder
// @author Brian Hartvigsen <bhartvigsen@opendns.com>
// @version 1.1.0
// @description Allow you to reorder your Apps to get the most important ones on top
// @match https://*.zendesk.com/agent/*
// @include https://*.zendesk.com/agent/*
// ==/UserScript==
function orderApps() {
order = [
'app-10954', // Answer Suggestion
'app-6848', // Five Most Recent
'app-10', // Salesforce
'app-5796' // Quick Search
];
jQuery.getScript("https://mutation-summary.googlecode.com/git/mutation_summary.js", function() {
var ms = null;
function handleChanges(changes) {
// ignore removals/deletions
if (changes[0].added.length <= 0) {
return;
}
// We are about to mess with the dom, so let's not listen to changes
ms.disconnect();
// Start at the end, instert it at the top of the list
// then loop through all the elements
_.each(order.slice(0).reverse(), function(appid){
var elem = jQuery("div.workspace:visible div.ember-view.app_view." + appid);
elem.insertAfter(elem.parent().find(".action_buttons"));
});
// and back to listening to changes
ms.reconnect();
}
jQuery(function(){
ms = new MutationSummary({
callback: handleChanges,
queries: [
{ element: "div.ember-view.custom.app_view" }
]
});
handleChanges([{added: [ true ]}]);
});
});
}
function addScript(js) {
var body = document.body, script = document.createElement('script');
if (!body) return;
script.type = 'text/javascript';
script.textContent = "(" + js + ")()";
body.appendChild(script);
}
addScript(orderApps);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment