diff --git a/main.js b/main.js index 46e17bd..875f364 100644 --- a/main.js +++ b/main.js @@ -1923,6 +1923,19 @@ function createTab(initial, opts = {}) { } if (p.isEditable) items.push({ role: "cut" }, { role: "copy" }, { role: "paste" }, { type: "separator" }); else if (p.selectionText) items.push({ role: "copy" }, { type: "separator" }); + // "Search for …" when text is selected. Label uses a short excerpt so + // a long selection doesn't stretch the menu. Opens in a new foreground + // tab so the current page isn't lost — matches Chrome / Firefox UX. + if (p.selectionText) { + const raw = p.selectionText.replace(/\s+/g, " ").trim(); + if (raw) { + const excerpt = raw.length > 40 ? raw.slice(0, 40) + "…" : raw; + items.push( + { label: `Search for "${excerpt.replace(/&/g, "&&")}"`, click: () => createTab(SEARCH(raw)) }, + { type: "separator" }, + ); + } + } items.push( { label: "Back", enabled: wc.navigationHistory.canGoBack(), click: () => wc.navigationHistory.goBack() }, { label: "Forward", enabled: wc.navigationHistory.canGoForward(), click: () => wc.navigationHistory.goForward() },