Skip to content

Commit

Permalink
(JS) extensionOptionsPanel: fix bug where
Browse files Browse the repository at this point in the history
the panel didn't work in successive windows.
navbarToolbarButtonSlider: fix bug affecting
customizing toolbar in private windows.
(CSS) add new styles and icons for the "private bookmarks" extension.
some other minor updates.
  • Loading branch information
aminomancer committed May 19, 2022
1 parent 093fe3a commit 5a50179
Show file tree
Hide file tree
Showing 12 changed files with 415 additions and 41 deletions.
32 changes: 18 additions & 14 deletions JS/extensionOptionsPanel.uc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Extension Options Panel
// @version 1.8.1
// @version 1.8.2
// @author aminomancer
// @homepage https://github.com/aminomancer/uc.css.js
// @description This script creates a toolbar button that opens a popup panel where extensions can be configured, disabled, uninstalled, etc. Each extension gets its own button in the panel. Clicking an extension's button leads to a subview where you can jump to the extension's options, disable or enable the extension, uninstall it, configure automatic updates, disable/enable it in private browsing, view its source code in whatever program is associated with .xpi files, open the extension's homepage, or copy the extension's ID. The panel can also be opened from the App Menu, using the built-in "Add-ons and themes" button. Since v1.8, themes will also be listed in the panel. Hovering a theme will show a tooltip with a preview/screenshot of the theme, and clicking the theme will toggle it on or off. There are several translation and configuration options directly below.
Expand Down Expand Up @@ -223,26 +223,30 @@ class ExtensionOptionsWidget {
tooltiptext: l10n["Button tooltip"],
// if the button is middle-clicked, open the addons page instead of the panel
onClick: (event) => {
if (event.button == 1) BrowserOpenAddonsMgr("addons://list/extension");
if (event.button == 1) {
event.target.ownerGlobal.BrowserOpenAddonsMgr("addons://list/extension");
}
},
// create the panelview before the toolbar button
onBeforeCreated: (aDoc) => {
let view = this.create(aDoc, "panelview", {
id: this.viewId,
let eop = aDoc.defaultView.extensionOptionsPanel;
if (!eop) return;
let view = eop.create(aDoc, "panelview", {
id: eop.viewId,
class: "PanelUI-subView cui-widget-panelview",
flex: "1",
style: "min-width:30em",
});
aDoc.getElementById("appMenu-viewCache").appendChild(view);
aDoc.defaultView.extensionOptionsPanel.panelview = view;

if (this.config["Show header"]) {
if (eop.config["Show header"]) {
let header = view.appendChild(
this.create(aDoc, "vbox", { id: "eom-mainView-panel-header" })
eop.create(aDoc, "vbox", { id: "eom-mainView-panel-header" })
);
let heading = header.appendChild(this.create(aDoc, "label"));
let heading = header.appendChild(eop.create(aDoc, "label"));
let label = heading.appendChild(
this.create(aDoc, "html:span", {
eop.create(aDoc, "html:span", {
id: "eom-mainView-panel-header-span",
role: "heading",
"aria-level": "1",
Expand All @@ -253,34 +257,34 @@ class ExtensionOptionsWidget {
}

view.appendChild(
this.create(aDoc, "vbox", {
eop.create(aDoc, "vbox", {
id: view.id + "-body",
class: "panel-subview-body",
})
);

// create the theme preview tooltip
aDoc.getElementById("mainPopupSet").appendChild(
MozXULElement.parseXULToFragment(
aDoc.defaultView.MozXULElement.parseXULToFragment(
`<tooltip id="eom-theme-preview-tooltip" noautohide="true" orient="vertical" onpopupshowing="extensionOptionsPanel.onTooltipShowing(event);"><vbox id="eom-theme-preview-box"><html:img id="eom-theme-preview-canvas"></html:img></vbox></tooltip>`
)
);

this.fluentSetup(aDoc).then(() => this.swapAddonsButton(aDoc));
eop.fluentSetup(aDoc).then(() => eop.swapAddonsButton(aDoc));
},
// populate the panel before it's shown
onViewShowing: (event) => {
if (
event.originalTarget ===
event.target.ownerGlobal.extensionOptionsPanel.panelview
event.target.ownerGlobal.extensionOptionsPanel?.panelview
)
event.target.ownerGlobal.extensionOptionsPanel.getAddonsAndPopulate(event);
},
// delete the panel if the widget node is destroyed
onDestroyed: (aDoc) => {
let view = aDoc.getElementById(this.viewId);
let view = aDoc.getElementById(aDoc.defaultView.extensionOptionsPanel?.viewId);
if (view) {
CustomizableUI.hidePanelForNode(view);
aDoc.defaultView.CustomizableUI.hidePanelForNode(view);
view.remove();
}
},
Expand Down
8 changes: 5 additions & 3 deletions JS/navbarToolbarButtonSlider.uc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// ==UserScript==
// @name Navbar Toolbar Button Slider
// @version 2.8.0
// @version 2.8.1
// @author aminomancer
// @homepage https://github.com/aminomancer
// @description Wrap all toolbar buttons in a scrollable container. It can scroll horizontally through the buttons by scrolling up/down with a mousewheel, like the tab bar. By default, it wraps all toolbar buttons that come after the urlbar (to the right of the urlbar for left-to-right languages). You can edit userChrome.toolbarSlider.wrapButtonsRelativeToUrlbar in about:config to change this: a value of "before" will wrap all buttons that come before the urlbar, and "all" will wrap all buttons. You can change userChrome.toolbarSlider.width to make the container wider or smaller. If you choose 8, the slider will be 8 buttons long. When the window gets *really* small, the slider disappears and the toolbar buttons are placed into the normal widget overflow panel. (this can be disabled with userChrome.toolbarSlider.collapseSliderOnOverflow) You can specify more buttons to exclude from the slider by adding their IDs (in quotes, separated by commas) to userChrome.toolbarSlider.excludeButtons. For example you might type ["bookmarks-menu-button", "downloads-button"] if you want those to stay outside of the slider. You can also decide whether to exclude flexible space springs from the slider by toggling userChrome.toolbarSlider.excludeFlexibleSpace. By default, springs are excluded. To scroll faster you can add a multiplier right before scrollByPixels is called, like scrollAmount = scrollAmount * 1.5 or something like that.
Expand Down Expand Up @@ -474,9 +474,11 @@ class NavbarToolbarSlider {
} else parent.insertBefore(this.outer, parent.firstElementChild);
}
unwrapAll() {
let orderedWidgets = CustomizableUI.getWidgetsInArea("nav-bar").filter(Boolean);
let orderedWidgets = CustomizableUI.getWidgetsInArea("nav-bar")
.filter(Boolean)
.filter((item) => !!item.forWindow(window)?.node);
orderedWidgets.forEach((w, i) => {
let node = w.forWindow(window).node;
let node = w.forWindow(window)?.node;
let prevWidget = orderedWidgets[i - 1];
if (prevWidget) prevWidget.forWindow(window).node.after(node);
else this.cTarget.appendChild(node);
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ I also recommend setting the following prefs in `about:config`. There are two pr
| widget.non-native-theme.gtk.scrollbar.thumb-size | Number | 0.818 | Make the scrollbar thumb 9px wide for GTK |
| userChrome.css.remove-tooltip-borders | Boolean | false | Remove the thin border on tooltips. Not recommended |
| userChrome.css.titlebar-buttons-on-left | Boolean | false | If true, move the titlebar buttons (close/min/max) to the left side of the window |
| userChrome.css.ctrl-tab-backdrop-overlay | Boolean | true | If true, dim the rectangular area behind the Ctrl+tab panel to increase contrast |
| userChrome.css.wikipedia.dark-theme-enabled | Boolean | true | Enable the custom dark theme for Wikipedia.org |
| userChrome.findbar.hide-on-unfocus | Boolean | false | Automatically hide the findbar when you blur (unfocus) it |
| userChrome.panels.allow-height-flex | Boolean | false | If true, allow panels to flex down in height. Will cause stutters on weaker hardware |
Expand Down
Loading

0 comments on commit 5a50179

Please sign in to comment.