Last active
August 18, 2016 17:32
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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 <[email protected]> | |
// @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); | |
} | |
} | |
); | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.