Skip to content

Commit d3d367d

Browse files
committed
(JS) fix restorePreProtonArrowpanels.
it was previously not setting the open attribute on urlbar buttons. refactor a few other scripts. (CSS) minor improvements to bookmarks toolbar animations.
1 parent 7b961ce commit d3d367d

8 files changed

Lines changed: 3062 additions & 2914 deletions

JS/appMenuAboutConfigButton.uc.js

Lines changed: 82 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -21,93 +21,99 @@
2121
// ==/UserScript==
2222

2323
(function () {
24-
// user configuration
25-
const config = {
26-
urlOverride: "",
27-
/* the script tries to automatically find earthlng's aboutconfig URL, and if it can't be
28-
found, uses the built-in about:config URL instead. if it's unable to find the URL for your
29-
particular setup, or if you just want to use the vanilla about:config page, replace this
30-
empty string with your preferred URL, in quotes. if you want to use my about:cfg script that
31-
registers earthlng's aboutconfig page to about:cfg, and you want the about:config button to
32-
take you to about:cfg, then leave this empty. it will automatically use about:cfg if the
33-
script exists. if about:cfg doesn't work for you then change the urlOverride in *that*
34-
script instead of this one. */
35-
};
24+
// user configuration
25+
const config = {
26+
urlOverride: "",
27+
/* the script tries to automatically find earthlng's aboutconfig URL,
28+
and if it can't be found, uses the built-in about:config URL instead. if
29+
it's unable to find the URL for your particular setup, or if you just
30+
want to use the vanilla about:config page, replace this empty string
31+
with your preferred URL, in quotes. if you want to use my about:cfg
32+
script that registers earthlng's aboutconfig page to about:cfg, and you
33+
want the about:config button to take you to about:cfg, then leave this
34+
empty. it will automatically use about:cfg if the script exists. if
35+
about:cfg doesn't work for you then change the pathOverride in *that*
36+
script instead of setting urlOverride in this one. if you changed the
37+
address (the "cfg" string) in that script, you'll need to use
38+
urlOverride here if you want the button to direct to earthlng's
39+
aboutconfig page. so if for example you changed the address to "config2"
40+
then change urlOverride above to "about:config2" */
41+
};
3642

37-
let { interfaces: Ci, manager: Cm } = Components;
43+
let { interfaces: Ci, manager: Cm } = Components;
3844

39-
function findAboutConfig() {
40-
if (config.urlOverride) return config.urlOverride;
45+
function findAboutConfig() {
46+
if (config.urlOverride) return config.urlOverride;
4147

42-
if (
43-
Cm.QueryInterface(Ci.nsIComponentRegistrar).isContractIDRegistered(
44-
"@mozilla.org/network/protocol/about;1?what=cfg"
45-
)
46-
)
47-
return "about:cfg";
48+
if (
49+
Cm.QueryInterface(Ci.nsIComponentRegistrar).isContractIDRegistered(
50+
"@mozilla.org/network/protocol/about;1?what=cfg"
51+
)
52+
)
53+
return "about:cfg";
4854

49-
let dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
50-
let appendFn = (nm) => dir.append(nm);
55+
let dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
56+
let appendFn = nm => dir.append(nm);
5157

52-
// fx-autoconfig
53-
["resources", "aboutconfig", "config.xhtml"].forEach(appendFn);
54-
if (dir.exists()) return "chrome://userchrome/content/aboutconfig/config.xhtml";
58+
// fx-autoconfig
59+
["resources", "aboutconfig", "config.xhtml"].forEach(appendFn);
60+
if (dir.exists()) return "chrome://userchrome/content/aboutconfig/config.xhtml";
5561

56-
// earthlng's loader
57-
dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
58-
["utils", "aboutconfig", "config.xhtml"].forEach(appendFn);
59-
if (dir.exists()) return "chrome://userchromejs/content/aboutconfig/config.xhtml";
62+
// earthlng's loader
63+
dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
64+
["utils", "aboutconfig", "config.xhtml"].forEach(appendFn);
65+
if (dir.exists()) return "chrome://userchromejs/content/aboutconfig/config.xhtml";
6066

61-
// xiaoxiaoflood's loader
62-
dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
63-
["utils", "aboutconfig", "aboutconfig.xhtml"].forEach(appendFn);
64-
if (dir.exists()) return "chrome://userchromejs/content/aboutconfig/aboutconfig.xhtml";
67+
// xiaoxiaoflood's loader
68+
dir = Services.dirsvc.get("UChrm", Ci.nsIFile);
69+
["utils", "aboutconfig", "aboutconfig.xhtml"].forEach(appendFn);
70+
if (dir.exists()) return "chrome://userchromejs/content/aboutconfig/aboutconfig.xhtml";
6571

66-
// no about:config replacement found
67-
return "about:config";
68-
}
72+
// no about:config replacement found
73+
return "about:config";
74+
}
6975

70-
async function createButton() {
71-
// get fluent file for AboutConfig page
72-
const configStrings = await new Localization(["toolkit/about/config.ftl"], true);
73-
// localize the "Advanced Preferences" string
74-
const advancedPrefsLabel = await configStrings.formatValue(["about-config-page-title"]);
75-
const { mainView } = PanelUI;
76-
const doc = mainView.ownerDocument;
77-
const settingsButton =
78-
doc.getElementById("appMenu-settings-button") ??
79-
doc.getElementById("appMenu-preferences-button");
80-
const prefsButton = doc.createXULElement("toolbarbutton");
76+
async function createButton() {
77+
// get fluent file for AboutConfig page
78+
const configStrings = await new Localization(["toolkit/about/config.ftl"], true);
79+
// localize the "Advanced Preferences" string
80+
const advancedPrefsLabel = await configStrings.formatValue(["about-config-page-title"]);
81+
const { mainView } = PanelUI;
82+
const doc = mainView.ownerDocument;
83+
const settingsButton =
84+
doc.getElementById("appMenu-settings-button") ??
85+
doc.getElementById("appMenu-preferences-button");
86+
const prefsButton = doc.createXULElement("toolbarbutton");
8187

82-
prefsButton.preferredURL = findAboutConfig();
83-
for (const [key, val] of Object.entries({
84-
id: "appMenu-advanced-settings-button",
85-
class: "subviewbutton",
86-
label: advancedPrefsLabel,
87-
oncommand: `openTrustedLinkIn(this.preferredURL, gBrowser.currentURI.spec === AboutNewTab.newTabURL || gBrowser.currentURI.spec === HomePage.get(window) ? "current" : "tab")`,
88-
}))
89-
prefsButton.setAttribute(key, val);
90-
// place after the built-in "Settings" button
91-
settingsButton.after(prefsButton);
92-
}
88+
prefsButton.preferredURL = findAboutConfig();
89+
for (const [key, val] of Object.entries({
90+
id: "appMenu-advanced-settings-button",
91+
class: "subviewbutton",
92+
label: advancedPrefsLabel,
93+
oncommand: `openTrustedLinkIn(this.preferredURL, gBrowser.currentURI.spec === AboutNewTab.newTabURL || gBrowser.currentURI.spec === HomePage.get(window) ? "current" : "tab")`,
94+
}))
95+
prefsButton.setAttribute(key, val);
96+
// place after the built-in "Settings" button
97+
settingsButton.after(prefsButton);
98+
}
9399

94-
function init() {
95-
PanelMultiView.getViewNode(document, "appMenu-multiView").addEventListener(
96-
"ViewShowing",
97-
createButton,
98-
{ once: true }
99-
);
100-
}
100+
function init() {
101+
PanelMultiView.getViewNode(document, "appMenu-multiView").addEventListener(
102+
"ViewShowing",
103+
createButton,
104+
{ once: true }
105+
);
106+
}
101107

102-
if (gBrowserInit.delayedStartupFinished) {
108+
if (gBrowserInit.delayedStartupFinished) {
109+
init();
110+
} else {
111+
let delayedListener = (subject, topic) => {
112+
if (topic == "browser-delayed-startup-finished" && subject == window) {
113+
Services.obs.removeObserver(delayedListener, topic);
103114
init();
104-
} else {
105-
let delayedListener = (subject, topic) => {
106-
if (topic == "browser-delayed-startup-finished" && subject == window) {
107-
Services.obs.removeObserver(delayedListener, topic);
108-
init();
109-
}
110-
};
111-
Services.obs.addObserver(delayedListener, "browser-delayed-startup-finished");
112-
}
115+
}
116+
};
117+
Services.obs.addObserver(delayedListener, "browser-delayed-startup-finished");
118+
}
113119
})();

0 commit comments

Comments
 (0)