Created
August 22, 2024 15:31
-
-
Save lpar/e1da525639eb849858f7bedace54a425 to your computer and use it in GitHub Desktop.
Re-enable HTML edit in Freshdesk rich text editor
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 Freshdesk HTML edit reenable | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-08-22 | |
// @description Re-enables the HTML edit option in the Freshdesk reply editor | |
// @author [email protected] | |
// @match https://*.freshdesk.com/a/tickets/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=freshdesk.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function fixToolbar () { | |
const buttonGroup = document.querySelector(".fr-toolbar")?.lastChild; | |
if (!buttonGroup) { | |
setTimeout(fixToolbar, 5); | |
return; | |
} | |
const lastButton = buttonGroup.lastChild; | |
const lastButtonCmd = lastButton.getAttribute("data-cmd"); | |
if (lastButtonCmd === "html") { | |
return; | |
} | |
const htmlButton = lastButton.cloneNode(); | |
htmlButton.setAttribute("data-cmd", "html"); | |
htmlButton.setAttribute("data-title", "HTML"); | |
htmlButton.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="32" height="32" fill="none" stroke="black" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" class="app-icon app-icon--small" id="i-code"><path d="M10 9 L3 17 10 25 M22 9 L29 17 22 25 M18 7 L14 27"></path></svg>`; | |
buttonGroup.appendChild(htmlButton); | |
} | |
fixToolbar(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment