Open kenjiuno opened 4 years ago
https://github.com/HiraokaHyperTools/sample-extensions/tree/master/modifyWriteButton sample will replace builtin Write
button like following:
At first click [ModifyWriteButton] at top-right, and then click [ReplaceWriteButton] button:
Or you can try replacement of Write
button with privileged DevTool:
Console
tabnewToolbarButton = MozXULElement.parseXULToFragment(`
<toolbarbutton id="button-newmsg"
type="menu-button"
class="toolbarbutton-1"
label="Write"
tooltiptext="New message">
<menupopup is="menupopup">
<menuitem id="button-newmsg-1"
label="New message alternative 1"/>
<menuitem id="button-newmsg-2"
label="New message alternative 2"/>
<menuitem id="button-newmsg-3"
label="New message alternative 3"/>
</menupopup>
</toolbarbutton>
`)
newToolbarButton.querySelector("#button-newmsg-1").addEventListener("command", () => { alert("1"); event.stopPropagation(); })
newToolbarButton.querySelector("#button-newmsg-2").addEventListener("command", () => { alert("2") })
newToolbarButton.querySelector("#button-newmsg-3").addEventListener("command", () => { alert("3") })
doc = Services.wm.getMostRecentWindow(null).document
newMsg = doc.getElementById("button-newmsg")
newMsg.parentNode.replaceChild(newToolbarButton, newMsg)
newToolbarButton = doc.getElementById("button-newmsg")
newToolbarButton.addEventListener("command", () => alert("0"))
There are still more issues to be solved in this modifyWriteButton extension...
browser.modifyWriteButtonApi.replaceWriteButton()
function so that it can do practical actions.Write
button doesn't accept Customization like: moving position, and button removal.Write
button on shutdown)browser_action
message_display_action
compose_action
I have tested the script https://github.com/HiraokaHyperTools/sample-extensions/issues/1#issuecomment-625801050 on TB 68.8.0:
Quick research topic of Dropdown support for default menu entry Write,Reply,Forward, etc. | Topicbox
In TB 68 and prior, this kind of UI mutation has been done by writing add-on with
chrome.manifest
.That way is called
XUL Overlay (Cross Package Overlays)
.However since TB 74 Beta, add-on using XUL Overlay doesn't work any more. Because JavaScript execution context is separated now: Thunderbird privileged context and extension contexts.
TB dev team declares latest TB supports WebExtension (MailExtension) now.
TB still uses XUL. However add-on cannot access XUL directly.
TB dev team allowed us to use WebExtension Experiments in order to access privileged part of Thunderbird including XUL with JavaScript code.
So can we modify builtin
Write
button by writing WebExtension Experiments?