Skip to content

Commit

Permalink
[FB] Open in external | Add to context menu of link
Browse files Browse the repository at this point in the history
  • Loading branch information
typeling1578 committed Mar 12, 2023
1 parent a365ea2 commit 6608f5b
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions floorp/browser/components/OpenLinkInExternal.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ let documentObserver = {
(async () => {
let tabContextMenu = document_.querySelector("#tabContextMenu");
let openLinkInExternal = document_.createXULElement("menuitem");
openLinkInExternal.id = "open-link-in-external";
openLinkInExternal.id = "context_openLinkInExternal";
openLinkInExternal.label = await L10N.formatValue("open-link-in-external-tab-context-menu");
openLinkInExternal.addEventListener("command", function(e) {
let window_ = e.currentTarget.ownerGlobal;
Expand All @@ -365,11 +365,32 @@ let documentObserver = {
tabContextMenu.addEventListener("popupshowing", function(e) {
let window_ = e.currentTarget.ownerGlobal;
let scheme = window_.TabContextMenu.contextTab.linkedBrowser.currentURI.scheme;
e.currentTarget.querySelector("#open-link-in-external").hidden = !/https?/.test(scheme);
e.currentTarget.querySelector("#context_openLinkInExternal").hidden = !/https?/.test(scheme);
});
tabContextMenu.querySelector("#context_sendTabToDevice")
.insertAdjacentElement("afterend", openLinkInExternal);
})();
(async () => {
let contextMenu = document_.querySelector("#contentAreaContextMenu");
let openLinkInExternal = document_.createXULElement("menuitem");
openLinkInExternal.id = "context-openlinkinexternal";
openLinkInExternal.label = await L10N.formatValue("open-link-in-external-tab-context-menu");
openLinkInExternal.addEventListener("command", function(e) {
let window_ = e.currentTarget.ownerGlobal;
OpenLinkInExternal(window_.gContextMenu.linkURL);
});
contextMenu.addEventListener("popupshowing", function(e) {
let window_ = e.currentTarget.ownerGlobal;
let scheme = window_.gContextMenu.linkURL;
e.currentTarget.querySelector("#context-openlinkinexternal").hidden =
!(
window_.gContextMenu.onSaveableLink ||
window_.gContextMenu.onPlainTextLink
) || !/https?/.test(scheme);
});
contextMenu.querySelector("#context-sendlinktodevice")
.insertAdjacentElement("afterend", openLinkInExternal);
})();
} else if (window_.location.href.startsWith("chrome://browser/content/preferences/preferences.xhtml") ||
window_.location.href.startsWith("about:preferences")) {
window_.addEventListener("pageshow", async function() {
Expand Down

0 comments on commit 6608f5b

Please sign in to comment.