Created
July 27, 2018 14:56
-
-
Save theoBLT/eb1eb8ce2c1f99fe0201c1add78979cd to your computer and use it in GitHub Desktop.
TamperMonkey userscript providing a boilerplate to open other tools with data form Zendesk, with just a keyboard shortcut.
This file contains 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 Open User's Back-office page | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Open user's back-office page straight from Zendesk! | |
// @author Théo Blochet | |
// @match https://qonto.zendesk.com/agent/tickets/* | |
// @grant none | |
// ==/UserScript== | |
window.onload = function() { | |
function myFunc() { | |
var map = {}; | |
onkeydown = onkeyup = function(e) { // This listens for new keyboard | |
map[e.keyCode] = e.type == 'keydown'; | |
if (map[17] && map[85]) { // 17 means CTRL -on Mac- and 85 means U. That's CTRL+U. | |
var userEmail = document.querySelector('.email').innerText; //Here, capture whatever data you want to pass from Zendesk into the URL of your back-office tool | |
let backOfficeUrl= `http://localhost:8000/?email=${userEmail}`; //Replace the URL with you backoffice, and pass whatever variable captured above into the URL | |
window.open(backOfficeUrl); // This simply opens the URL in a new tab | |
map = {}; // This clears the array of keyboard keys pressed | |
} | |
} | |
} | |
setTimeout(myFunc, 500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment