How can I change the font selection in the GMail creation window from JavaScript?

I often mention code in my emails that I like to visually distinguish from the rest of the text. It's a huge pain to do this using the current interface.

I want to create a Chrome extension that will add a keyboard shortcut to switch the font in the GMail creation window to "Courier New" and back to "Sans Serif". This seems to be quite complicated as all the JS code is obfuscated.

+3


source to share


1 answer


This does not apply to menus, but you can simply edit the DOM of the email body directly. It seems like GMail is using <font face='courier new, monospace'>...</font>

to install the font, so you can just do it like this bookmarklet .



javascript:(function(){var selection=window.getSelection().getRangeAt(0);var selectedText=selection.extractContents();var font=document.createElement('font');font.face='courier new, monospace';font.appendChild(selectedText);selection.insertNode(font);})();

      

+7


source







All Articles