Google Mail Signature HTML Code Editor

Add an inputbox for editing the HTML code of message signature on General tab of the settings page

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name        Google Mail Signature HTML Code Editor
// @namespace   https://greasyfork.org/en/users/85671-jcunews
// @version     1.0.1
// @license     AGPL v3
// @author      jcunews
// @description Add an inputbox for editing the HTML code of message signature on General tab of the settings page
// @match       https://mail.google.com/mail/*
// @grant       none
// ==/UserScript==

((rxBlockTags, timerCheck, eleSigContainer, eleSigHtml, sigHtmlChanged, prevFormatted) => {
  function check(e) {
    if (eleSigContainer = document.querySelector('.Ia .editable[aria-label="Signature"]')) {
      if (!document.getElementById("sigHtml")) {
        if (e = eleSigContainer.closest('.Ia')) e.style.height = "auto";
        eleSigContainer.insertAdjacentHTML("beforebegin", `\
<div style="padding:0 .3em;background:#bdd;font-weight:bold">HTML Code</div>
<textarea id="sigHtml" style="box-sizing:border-box;width:100%;min-height:8em;resize:vertical;font:10pt/1.5em monospace"></textarea>
<div style="padding:0 .3em;background:#bdd;font-weight:bold">Formatted Content</div>`);
        (eleSigHtml = document.getElementById("sigHtml")).oninput = () => {
          sigHtmlChanged = true;
          eleSigContainer.innerHTML = eleSigHtml.value
        };
        prevFormatted = ""
      }
      if (sigHtmlChanged) {
        sigHtmlChanged = false
      } else if (eleSigContainer.innerHTML !== prevFormatted) {
        eleSigHtml.value = prevFormatted = eleSigContainer.innerHTML.replace(rxBlockTags, "$1\n$2")
      }
    } else eleSigContainer = eleSigHtml = null
  }
  rxBlockTags = new RegExp("(>)[ \\t]*?(<(?:\
aside|br|blockquote|body|caption|center|col(?:group)?|datalist|dd|details|dialog|di[rv]|\
fieldset|figcaption|figure|footer|form|frame(?:set)?|h[1-6r]|head(?:er)?|html|\
main|menu|nav|ol|option|p(?:re)|section|summary|table|td|tbody|tfoot|th(?:ead)?|tr|ul\
)>)", "gi");
  (new MutationObserver(recs => {
    clearTimeout(timerCheck);
    timerCheck = setTimeout(check, 100);
    timerCheck = 0
  })).observe(document, {childList: true, subtree: true})
})()