Skip to content

Instantly share code, notes, and snippets.

@tstachl
Last active August 18, 2016 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tstachl/7b85590b73e5c8b69ea791072131a838 to your computer and use it in GitHub Desktop.
Save tstachl/7b85590b73e5c8b69ea791072131a838 to your computer and use it in GitHub Desktop.
This is a quick user script that hooks into the 'desk.agent.case.detail' state and clicks the note button as soon as it is available.
// ==UserScript==
// @name Note
// @namespace http://www.desk.com/
// @version 0.2
// @description This script defaults new interactions in Desk.com Next Gen Agent to note rather than reply.
// @author Thomas Stachl <tstachl@salesforce.com>
// @match https://*/web/agent*
// @grant none
// ==/UserScript==
(function() {
'use strict';
if (!angular || !ds) {
return;
}
angular.element(document).ready(function() {
angular.element(document.querySelector('html'))
.scope().$on(
'$stateChangeSuccess',
function(event, toState, toParams, fromState, fromParams) {
if (toState.name === 'desk.agent.case.detail') {
var counter = 0;
var interval = setInterval(function() {
counter += 1;
var element = document.querySelector('a.note');
if (element) { element.click(); clearInterval(interval); }
if (counter > 5) { clearInterval(interval); }
}, 500);
}
}
);
});
})();
@tstachl
Copy link
Author

tstachl commented Aug 18, 2016

In the last update I added a counter because we want to make sure intervals are cleared in any case. This update has been tested in my development environment but let me know if there is any issue with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment