Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Move GMail Message View Toolbar Buttons To Top Toolbar
- // @namespace https://greasyfork.org/en/users/85671-jcunews
- // @version 1.0.2
- // @license AGPLv3
- // @author jcunews
- // @description https://www.reddit.com/r/userscripts/comments/r5m0rc/move_gmail_compose_buttons_to_top_of_conversation/
- // @match https://mail.google.com/mail/*
- // @grant none
- // @run-at document-end
- // ==/UserScript==
- (() => {
- if (!document.body) return;
- document.body.insertAdjacentHTML("beforeend", '<style> .cf.wS { display: none } </style>');
- (new MutationObserver(
- (btnTemplate, btns) => {
- if ((btns = document.querySelectorAll(".amn > .ams")).length) {
- if (
- (btnTemplate = document.querySelector(".bzn .G-Ni:nth-child(2)")) &&
- !document.querySelector(".btnShortcut")
- ) {
- btns.forEach((btn, i, newBtn) => {
- newBtn = btnTemplate.cloneNode(true);
- newBtn.dataset.btnindex = i;
- newBtn.classList.add("btnShortcut");
- newBtn.firstElementChild.removeAttribute("act");
- newBtn.querySelector(".Bn").textContent = btn.textContent;
- newBtn.addEventListener("click", function(ev) {
- if (ev.button) return;
- ev.stopImmediatePropagation();
- ev.stopPropagation();
- ev.preventDefault();
- document.querySelectorAll(`.amn > .ams`)[this.dataset.btnindex].click();
- }, true);
- btnTemplate.parentNode.insertBefore(newBtn, btnTemplate);
- });
- }
- } else document.querySelectorAll(".btnShortcut").forEach(e => e.remove());
- }
- )).observe(document.body, {childList: true, subtree: true});
- })();
Add Comment
Please, Sign In to add comment