|
// ==UserScript== |
|
// @name MinMaxClose Button |
|
// @author xiaoxiaoflood |
|
// @include main |
|
// @shutdown UC.MinMaxCloseButton.destroy(); |
|
// @onlyonce |
|
// ==/UserScript== |
|
|
|
// inspired by: https://j.mozest.com/ucscript/script/83.meta.js |
|
|
|
UC.MinMaxCloseButton = { |
|
init: function () { |
|
_uc.sss.loadAndRegisterSheet(this.STYLE, _uc.sss.USER_SHEET); |
|
const { CustomizableUI } = window; |
|
CustomizableUI.createWidget({ |
|
id: 'minMaxClose-button', |
|
type: 'custom', |
|
defaultArea: CustomizableUI.AREA_NAVBAR, |
|
onBuild: function (doc) { |
|
let btn = _uc.createElement(doc, 'toolbarbutton', { |
|
id: 'minMaxClose-button', |
|
class: 'toolbarbutton-1 chromeclass-toolbar-additional', |
|
label: 'Window Button', |
|
tooltiptext: 'Left-Click: Minimize\nMiddle-Click: Maximize/Restore to previous position\nRight-Click: Exit', |
|
oncontextmenu: 'return false', |
|
onclick: 'UC.MinMaxCloseButton.BrowserManipulateCombine(event)' |
|
}); |
|
|
|
return btn; |
|
} |
|
}); |
|
}, |
|
|
|
BrowserManipulateCombine: function (e) { |
|
let win = e.view; |
|
switch (e.button) { |
|
case 0: |
|
win.minimize(); |
|
break; |
|
case 1: |
|
let max = win.document.getElementById('main-window').getAttribute('sizemode') == 'maximized' ? true : false; |
|
if (max) { |
|
win.restore(); |
|
} else { |
|
win.maximize(); |
|
} |
|
break; |
|
case 2: |
|
win.close(); |
|
} |
|
}, |
|
|
|
STYLE: Services.io.newURI('data:text/css;charset=UTF-8,' + encodeURIComponent(` |
|
@-moz-document url('${_uc.BROWSERCHROME}') { |
|
@media (prefers-color-scheme: dark) { |
|
#minMaxClose-button { |
|
list-style-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAa0lEQVQ4T72SQQ4AIQgD5f+PVjnUQ7fdZUMiNw2ZjkLMXYMqdvGdO0cb4MgKnL1sZ1XbAGWW0E+Dt+R7ANZEctnAAdS/PKagUtQdYBIgk8x2llcW08Hzzrm689nHI05Y2QBBbPIL0DJwf7AAeTpgCcCBOFsAAAAASUVORK5CYII='); |
|
} |
|
} |
|
@media (prefers-color-scheme: light) { |
|
#minMaxClose-button { |
|
list-style-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAO0lEQVQ4jWNgYGD4jwWTBCg2gBSDSTKcYgNwGUqRzfQzAJcYxQYQBahiAE0SF7pBVEn2VHEJ/VyANQwACylDvQ9eqkEAAAAASUVORK5CYII='); |
|
} |
|
} |
|
} |
|
`)), |
|
|
|
destroy: function () { |
|
Services.wm.getMostRecentBrowserWindow().CustomizableUI.destroyWidget('minMaxClose-button'); |
|
_uc.sss.unregisterSheet(this.STYLE, _uc.sss.USER_SHEET); |
|
delete UC.MinMaxCloseButton; |
|
} |
|
} |
|
|
|
UC.MinMaxCloseButton.init(); |
Simplified version of MinMaxClose Button from https://github.com/xiaoxiaoflood/firefox-scripts
Middle-Click will now just restore/maximize window, instead of having extended feature of restoring to certain hard-coded values.