Skip to content

Instantly share code, notes, and snippets.

@tstachl tstachl/Note.user.js
Last active Aug 18, 2016

Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.