/
about_button.uc.js
67 lines (54 loc) · 1.77 KB
/
about_button.uc.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// 'about:'-Button script for Firefox 89+ by Aris
//
// Need a different 'about' page button?
// - replace 'about:config' url with a different 'about:' url
// - replace button id
// - replace icon / icon url / icon color
(function() {
try {
Components.utils.import("resource:///modules/CustomizableUI.jsm");
ChromeUtils.importESModule("resource:///modules/CustomizableUI.sys.mjs");
var sss = Components.classes["@mozilla.org/content/style-sheet-service;1"].getService(Components.interfaces.nsIStyleSheetService);
var button_label = "About Button";
CustomizableUI.createWidget({
id: "about-button", // button id
defaultArea: CustomizableUI.AREA_NAVBAR,
removable: true,
label: button_label, // button title
tooltiptext: button_label, // tooltip title
onClick: function(event) {
var win = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator)
.getMostRecentWindow("navigator:browser");
if(event.button=='0') {
try {
openAboutDialog();
} catch (e) {}
}
if(event.button=='2') {
try {
win.gBrowser.selectedTab = win.gBrowser.addTrustedTab('about:config');
setTimeout(function(){
document.querySelector("#toolbar-context-menu").hidePopup();
},0);
} catch (e) {}
}
},
onCreated: function(button) {
return button;
}
});
// style button icon
var uri = Services.io.newURI("data:text/css;charset=utf-8," + encodeURIComponent('\
\
#about-button .toolbarbutton-icon {\
list-style-image: url("chrome://global/skin/icons/defaultFavicon.svg"); /* icon / path to icon */ \
fill: dimgray; /* icon color name/code */\
}\
\
'), null, null);
sss.loadAndRegisterSheet(uri, sss.AGENT_SHEET);
} catch (e) {
Components.utils.reportError(e);
};
})();