Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ https://github.com/user-attachments/assets/cd79d644-ca2c-4a30-ae8e-c265f41768b6

- Actions: `Create` • `Delete` • `Edit` • `Change position and size` • `Reset position and size` • `Unload` • `Mute` • `Unmute` • `Pin` • `Unpin` • `Change zoom` • `Go back` • `Go forward` • `Reload` • `Go home`
- Extensions support
- Link context menu: `Open Link in Second Sidebar` • `Preview Link in Second Sidebar` (shown only for links that Firefox can open in a tab)
- Popup notifications support (permissions to use microphone/camera/location, etc.)
- Settings:
- General: `URL` • `Multi-Account Container` • `Temporary` • `Mobile view` • `Zoom`
Expand Down
13 changes: 12 additions & 1 deletion src/second_sidebar/controllers/context_menu_items.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export class ContextMenuItemsController {
#setupListeners() {
BrowserElements.contentAreaContextMenu.addEventListener(
"popupshowing",
() => this.#onPopupShowing(),
(event) => {
if (event.target !== event.currentTarget) return;
this.#onPopupShowing();
},
);

SidebarElements.openLinkAsWebPanelMenuItem.addEventListener("command", () =>
Expand All @@ -32,6 +35,14 @@ export class ContextMenuItemsController {
}

#onPopupShowing() {
const hideLinkItems = !gContextMenu.onSaveableLink;
SidebarElements.openLinkAsWebPanelMenuItem.toggleHidden(hideLinkItems);
SidebarElements.openLinkAsTempWebPanelMenuItem.toggleHidden(hideLinkItems);
gContextMenu.showItem(
"context-sep-open",
gContextMenu.shouldShowSeparator("context-sep-open"),
);

this.searchQuery = gContextMenu.selectedText || gContextMenu.linkTextStr;
SidebarElements.searchInWebPanelMenuItem.setSearchQuery(this.searchQuery);
}
Expand Down
4 changes: 3 additions & 1 deletion src/second_sidebar/controllers/sidebar.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ export class SidebarController {
const webPanelController =
SidebarControllers.webPanelsController.getActive();
this.close();
webPanelController.unload();
if (!webPanelController.isUnloaded()) {
webPanelController.unload();
}
});

listenEvent(SidebarEvents.EDIT_SIDEBAR_POSITION, (event) => {
Expand Down
6 changes: 0 additions & 6 deletions src/second_sidebar/css/context_item.mjs
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
export const CONTEXT_ITEM_CSS = `
#contentAreaContextMenu:has(#context-openlink[hidden="true"]) {
#context-openlinkaswebpanel, #context-openlinkastempwebpanel, #context-sep-open {
display: none;
}
}

menuitem[label="Reset Zoom [100%]"] {
display: none;
}
Expand Down
5 changes: 4 additions & 1 deletion src/second_sidebar/css/sidebar_main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ export const SIDEBAR_MAIN_CSS = `
}

.sb2-main-button[temporary="true"] > stack.toolbarbutton-badge-stack {
background-color: var(--attention-dot-color) !important;
background-color: var(
--attention-dot-color,
var(--button-attention-dot-color, var(--color-accent-attention, AccentColor))
) !important;
}

.sb2-main-button:not([image]):not([loading]) .toolbarbutton-icon {
Expand Down
14 changes: 14 additions & 0 deletions src/second_sidebar/patchers/urlbar_input_patcher.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export class UrlbarInputPatcher {
static patch() {
console.log("Patching #urlbar-input...");
this.#defineLazyGetter();
this.#patchTabSwitchFocusChange();
console.log("#urlbar-input was patched");
}

Expand All @@ -10,4 +11,17 @@ export class UrlbarInputPatcher {
const urlbarInput = childWindow.document.querySelector("#urlbar-input");
ChromeUtils.defineLazyGetter(urlbarInput, "editor", () => null);
}

static #patchTabSwitchFocusChange() {
const urlbar = window[1].gURLBar;
const afterTabSelectAndFocusChange = urlbar._afterTabSelectAndFocusChange;
if (typeof afterTabSelectAndFocusChange !== "function") return;

urlbar._afterTabSelectAndFocusChange = function (...args) {
// The hidden urlbar may have no view. Its focus handler must not
// interrupt tab removal before the temporary panel is deleted.
if (!this.view) return;
return afterTabSelectAndFocusChange.apply(this, args);
};
}
}
9 changes: 9 additions & 0 deletions src/second_sidebar/xul/base/xul_element.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ export class XULElement {
return this.setAttribute("hidden", true);
}

/**
*
* @param {boolean} [force]
* @returns {XULElement}
*/
toggleHidden(force) {
return this.toggleAttribute("hidden", force);
}

/**
*
* @returns {boolean}
Expand Down
Loading