Closed niceboy76 closed 6 years ago
I have the 2 following codes (if you need it) :
``var pinnedTabImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABXklEQVQ4jb2RS0sCYRiFv/8VZGUbpYugaNkiIgyqRbRv9EtpETVZgo2WoWljyCQ6Y7uYVVguUhrofxjePm/DaREFUQ5Ti571+5xz4CXEJIWalzN7+yMC86BQddE/yYWam0v1VhFnHuSf5n63pFBzc+meD7LuR1HfwWnHCaliMxeSr7ppureGos4h0nYg0V2GPOQQbTkgPk5T0/Jxcxb7DStOWvNQdIpztoDD5iQy5YmvIfKzNxhji0j1fLjub0EeBsA37Nh7teCoMQN5SJFgSxAfrEHD5jjzoDj0I8M2EaqPgW/YoAx2kWBeiOUp4+mEEJKrbN8IHSeUQQDpzgZKg9B7syk5l6OqquL25aIebTug9CmuuuvmZEmSOFVVoWkaFEXB2d1KKdKyI9Z2wXSzpmmQZRk8z1NCCBHLU/SgaTEOGCV/cHk/bjw/m81+zg6Hw6NfNIpkMglBEL41/wtv37oAkWZ0MmIAAAAASUVORK5CYII="; var unpinnedTabImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABTUlEQVQ4jb2Rv07CUByF73thECqYNEIDpGlroyHyxwiDxBluuelOGJkIGwnBBZz7CA4dHH0GbEu9LbQ5DkYSo2B18JvucL9zTvIjJCGhptOkf78lUFT4ssz+JHNFo2GtDq5o8KXS75ZwRaNho4mYUsTdLnhFhi+eJQvxFYVtmteIez34pRKCavX9LZXh5E5ZMplSrItFuIKAtSQhZgxc1eFl83AywucQrutmoJ0jrDewue0gMgy4ooiXdBpeoYCIMXD9Al42bx5s5qqGiBrg7TZWqRRcUdzJjvDDdEIIee7c3b9WZERGH7zVwtY0wfXLZPJsNmOWZeFpPF75UhnbPkNw00omz+dzalkWbNvGcrnE41XtYS0W4MsqEjfbto3FYoHBYMAIIcTJ5Jh3fHI4YJ/8gXOUOTx/Op3uZg+Hw/0n2sdkMsFoNPrS/C+8AY8W8RU9HpTEAAAAAElFTkSuQmCC";
this.tabContainerListener = function(aE) { var tab = aE.target; switch (aE.type) { case "TabAttrModified": case "TabClose": case "TabOpen": case "TabPinned": case "TabUnpinned": setButtonState(); break; } };
let tC = gBrowser.tabContainer; tC.addEventListener("TabAttrModified", this.tabContainerListener, false); tC.addEventListener("TabClose", this.tabContainerListener, false); tC.addEventListener("TabOpen", this.tabContainerListener, false); tC.addEventListener("TabPinned", this.tabContainerListener, false); tC.addEventListener("TabUnpinned", this.tabContainerListener, false);
function setButtonState() { if (gBrowser.selectedTab.getAttribute("pinned") == "true") { self.image = pinnedTabImage; } else { self.image = unpinnedTabImage; } }
function togglePinTab(aE) { var win = aE.target.ownerDocument.defaultView; if (win.gBrowser.selectedTab.getAttribute("pinned") == "true") { win.gBrowser.unpinTab(win.gBrowser.selectedTab); } else { win.gBrowser.pinTab(win.gBrowser.selectedTab); } setButtonState(); }
this.onclick = function(aE) { if (aE.button === 0) togglePinTab(aE); };
addDestructor(function(aReason) { if (aReason === "update" || aReason === "delete") { let tC = gBrowser.tabContainer; tC.removeEventListener("TabAttrModified", this.tabContainerListener, false); tC.removeEventListener("TabClose", this.tabContainerListener, false); tC.removeEventListener("TabOpen", this.tabContainerListener, false); tC.removeEventListener("TabPinned", this.tabContainerListener, false); tC.removeEventListener("TabUnpinned", this.tabContainerListener, false); } });
setButtonState();``
``togglePinTab();
function togglePinTab() { if (gBrowser.selectedTab.getAttribute("pinned") == "true") { gBrowser.unpinTab(gBrowser.selectedTab); } else { gBrowser.pinTab(gBrowser.selectedTab); } }``
I don't even know if it's the right language :) !!!!
Thanks for your time.
It would be great if you can create a javascript file to pin/unpin a tab with just a long left click with the mouse on the tab because I already have :
Thanks a lot for your hard work !!!!!!
Best Regards.
Nice76