mirror of
https://github.com/zen-browser/desktop.git
synced 2026-03-30 20:31:53 +00:00
feat: Copy current url now strips tracking parameters, b=no-bug, c=common, tabs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/customizableui/CustomizableUI.sys.mjs b/browser/components/customizableui/CustomizableUI.sys.mjs
|
||||
index d9a059f608779fea7cd8c595a432f6fe95183e0c..97fbe5f7ac2c5bf18526528a8f50dcf4466fcafd 100644
|
||||
index d9a059f608779fea7cd8c595a432f6fe95183e0c..09a7c4045afd0b96027d0bbbad22e02e52fd7b22 100644
|
||||
--- a/browser/components/customizableui/CustomizableUI.sys.mjs
|
||||
+++ b/browser/components/customizableui/CustomizableUI.sys.mjs
|
||||
@@ -14,6 +14,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||
@@ -153,6 +153,15 @@ index d9a059f608779fea7cd8c595a432f6fe95183e0c..97fbe5f7ac2c5bf18526528a8f50dcf4
|
||||
/**
|
||||
* Add a widget to an area.
|
||||
* If the area to which you try to add is not known to CustomizableUI,
|
||||
@@ -7866,7 +7866,7 @@ class OverflowableToolbar {
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
- sum += parseFloat(style.marginLeft) + parseFloat(style.marginRight);
|
||||
+ sum += parseFloat(style.marginLeft) + Math.max(0, parseFloat(style.marginRight));
|
||||
if (child != aExceptChild) {
|
||||
sum += getInlineSize(child);
|
||||
}
|
||||
@@ -7890,11 +7890,11 @@ class OverflowableToolbar {
|
||||
parseFloat(style.paddingLeft) -
|
||||
parseFloat(style.paddingRight) -
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
diff --git a/browser/components/urlbar/UrlbarInput.sys.mjs b/browser/components/urlbar/UrlbarInput.sys.mjs
|
||||
index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2b69f0cf7 100644
|
||||
index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..ea4f649026077fb6ce9d02b5fe3785c3a28e1f97 100644
|
||||
--- a/browser/components/urlbar/UrlbarInput.sys.mjs
|
||||
+++ b/browser/components/urlbar/UrlbarInput.sys.mjs
|
||||
@@ -76,6 +76,13 @@ ChromeUtils.defineLazyGetter(lazy, "logger", () =>
|
||||
@@ -75,7 +75,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
}
|
||||
|
||||
if (isCanonized) {
|
||||
@@ -2298,6 +2330,17 @@ export class UrlbarInput {
|
||||
@@ -2298,6 +2330,32 @@ export class UrlbarInput {
|
||||
await this.#updateLayoutBreakoutDimensions();
|
||||
}
|
||||
|
||||
@@ -89,11 +89,26 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
+ }
|
||||
+ return lazy.ZEN_URLBAR_BEHAVIOR;
|
||||
+ }
|
||||
+
|
||||
+ get zenStrippedURI() {
|
||||
+ let strippedURI = null;
|
||||
+
|
||||
+ // Error check occurs during isClipboardURIValid
|
||||
+ let uri = this.window.gBrowser.currentURI;
|
||||
+ try {
|
||||
+ strippedURI = lazy.QueryStringStripper.stripForCopyOrShare(uri);
|
||||
+ } catch (e) {
|
||||
+ console.warn(`stripForCopyOrShare: ${e.message}`);
|
||||
+ return [uri, lazy.ClipboardHelper];
|
||||
+ }
|
||||
+
|
||||
+ return [strippedURI ? this.makeURIReadable(strippedURI) : uri, lazy.ClipboardHelper];
|
||||
+ }
|
||||
+
|
||||
startLayoutExtend() {
|
||||
if (!this.#allowBreakout || this.hasAttribute("breakout-extend")) {
|
||||
// Do not expand if the Urlbar does not support being expanded or it is
|
||||
@@ -2312,6 +2355,12 @@ export class UrlbarInput {
|
||||
@@ -2312,6 +2370,12 @@ export class UrlbarInput {
|
||||
|
||||
this.setAttribute("breakout-extend", "true");
|
||||
|
||||
@@ -106,7 +121,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
// Enable the animation only after the first extend call to ensure it
|
||||
// doesn't run when opening a new window.
|
||||
if (!this.hasAttribute("breakout-extend-animate")) {
|
||||
@@ -2331,6 +2380,24 @@ export class UrlbarInput {
|
||||
@@ -2331,6 +2395,24 @@ export class UrlbarInput {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,7 +146,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
this.removeAttribute("breakout-extend");
|
||||
this.#updateTextboxPosition();
|
||||
}
|
||||
@@ -2660,7 +2727,7 @@ export class UrlbarInput {
|
||||
@@ -2660,7 +2742,7 @@ export class UrlbarInput {
|
||||
|
||||
this.textbox.parentNode.style.setProperty(
|
||||
"--urlbar-container-height",
|
||||
@@ -140,7 +155,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
);
|
||||
this.textbox.style.setProperty(
|
||||
"--urlbar-height",
|
||||
@@ -3093,6 +3160,7 @@ export class UrlbarInput {
|
||||
@@ -3093,6 +3175,7 @@ export class UrlbarInput {
|
||||
}
|
||||
|
||||
_toggleActionOverride(event) {
|
||||
@@ -148,7 +163,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
if (
|
||||
event.keyCode == KeyEvent.DOM_VK_SHIFT ||
|
||||
event.keyCode == KeyEvent.DOM_VK_ALT ||
|
||||
@@ -3197,7 +3265,7 @@ export class UrlbarInput {
|
||||
@@ -3197,7 +3280,7 @@ export class UrlbarInput {
|
||||
return val;
|
||||
}
|
||||
let trimmedValue = lazy.UrlbarPrefs.get("trimURLs")
|
||||
@@ -157,7 +172,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
: val;
|
||||
// Only trim value if the directionality doesn't change to RTL and we're not
|
||||
// showing a strikeout https protocol.
|
||||
@@ -3501,6 +3569,7 @@ export class UrlbarInput {
|
||||
@@ -3501,6 +3584,7 @@ export class UrlbarInput {
|
||||
resultDetails = null,
|
||||
browser = this.window.gBrowser.selectedBrowser
|
||||
) {
|
||||
@@ -165,7 +180,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
if (this.isAddressbar) {
|
||||
this.#prepareAddressbarLoad(
|
||||
url,
|
||||
@@ -3608,6 +3677,10 @@ export class UrlbarInput {
|
||||
@@ -3608,6 +3692,10 @@ export class UrlbarInput {
|
||||
}
|
||||
reuseEmpty = true;
|
||||
}
|
||||
@@ -176,7 +191,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
if (
|
||||
where == "tab" &&
|
||||
reuseEmpty &&
|
||||
@@ -3615,6 +3688,9 @@ export class UrlbarInput {
|
||||
@@ -3615,6 +3703,9 @@ export class UrlbarInput {
|
||||
) {
|
||||
where = "current";
|
||||
}
|
||||
@@ -186,7 +201,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
return where;
|
||||
}
|
||||
|
||||
@@ -3872,6 +3948,7 @@ export class UrlbarInput {
|
||||
@@ -3872,6 +3963,7 @@ export class UrlbarInput {
|
||||
this.setResultForCurrentValue(null);
|
||||
this.handleCommand();
|
||||
this.controller.clearLastQueryContextCache();
|
||||
@@ -194,7 +209,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
|
||||
this._suppressStartQuery = false;
|
||||
});
|
||||
@@ -3879,7 +3956,6 @@ export class UrlbarInput {
|
||||
@@ -3879,7 +3971,6 @@ export class UrlbarInput {
|
||||
contextMenu.addEventListener("popupshowing", () => {
|
||||
// Close the results pane when the input field contextual menu is open,
|
||||
// because paste and go doesn't want a result selection.
|
||||
@@ -202,7 +217,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
|
||||
let controller =
|
||||
this.document.commandDispatcher.getControllerForCommand("cmd_paste");
|
||||
@@ -3991,7 +4067,11 @@ export class UrlbarInput {
|
||||
@@ -3991,7 +4082,11 @@ export class UrlbarInput {
|
||||
if (!engineName && !source && !this.hasAttribute("searchmode")) {
|
||||
return;
|
||||
}
|
||||
@@ -215,7 +230,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
if (this._searchModeIndicatorTitle) {
|
||||
this._searchModeIndicatorTitle.textContent = "";
|
||||
this._searchModeIndicatorTitle.removeAttribute("data-l10n-id");
|
||||
@@ -4302,6 +4382,7 @@ export class UrlbarInput {
|
||||
@@ -4302,6 +4397,7 @@ export class UrlbarInput {
|
||||
|
||||
this.document.l10n.setAttributes(
|
||||
this.inputField,
|
||||
@@ -223,7 +238,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
l10nId,
|
||||
l10nId == "urlbar-placeholder-with-name" ? { name } : undefined
|
||||
);
|
||||
@@ -4413,6 +4494,11 @@ export class UrlbarInput {
|
||||
@@ -4413,6 +4509,11 @@ export class UrlbarInput {
|
||||
}
|
||||
|
||||
_on_click(event) {
|
||||
@@ -235,7 +250,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
if (
|
||||
event.target == this.inputField ||
|
||||
event.target == this._inputContainer
|
||||
@@ -4485,7 +4571,7 @@ export class UrlbarInput {
|
||||
@@ -4485,7 +4586,7 @@ export class UrlbarInput {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +259,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
this.view.autoOpen({ event });
|
||||
} else {
|
||||
if (this._untrimOnFocusAfterKeydown) {
|
||||
@@ -4525,9 +4611,16 @@ export class UrlbarInput {
|
||||
@@ -4525,9 +4626,16 @@ export class UrlbarInput {
|
||||
}
|
||||
|
||||
_on_mousedown(event) {
|
||||
@@ -262,7 +277,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
|
||||
if (
|
||||
event.target != this.inputField &&
|
||||
@@ -4538,6 +4631,10 @@ export class UrlbarInput {
|
||||
@@ -4538,6 +4646,10 @@ export class UrlbarInput {
|
||||
|
||||
this.focusedViaMousedown = !this.focused;
|
||||
this._preventClickSelectsAll = this.focused;
|
||||
@@ -273,7 +288,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
|
||||
// Keep the focus status, since the attribute may be changed
|
||||
// upon calling this.focus().
|
||||
@@ -4573,7 +4670,7 @@ export class UrlbarInput {
|
||||
@@ -4573,7 +4685,7 @@ export class UrlbarInput {
|
||||
}
|
||||
// Don't close the view when clicking on a tab; we may want to keep the
|
||||
// view open on tab switch, and the TabSelect event arrived earlier.
|
||||
@@ -282,7 +297,7 @@ index afc7a6c6ddbf4cf5a5b27c0bd60577b833c63093..a2494f2c0f3e4fc50cbe2fe3bf6e2bd2
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -4890,7 +4987,7 @@ export class UrlbarInput {
|
||||
@@ -4890,7 +5002,7 @@ export class UrlbarInput {
|
||||
// When we are in actions search mode we can show more results so
|
||||
// increase the limit.
|
||||
let maxResults =
|
||||
|
||||
@@ -68,58 +68,36 @@ class nsZenPreloadedFeature {
|
||||
|
||||
var gZenCommonActions = {
|
||||
copyCurrentURLToClipboard() {
|
||||
const currentUrl = gBrowser.currentURI.spec;
|
||||
if (currentUrl) {
|
||||
let str = Cc['@mozilla.org/supports-string;1'].createInstance(Ci.nsISupportsString);
|
||||
str.data = currentUrl;
|
||||
let transferable = Cc['@mozilla.org/widget/transferable;1'].createInstance(
|
||||
Ci.nsITransferable
|
||||
);
|
||||
transferable.init(window.docShell.QueryInterface(Ci.nsILoadContext));
|
||||
transferable.addDataFlavor('text/plain');
|
||||
transferable.setTransferData('text/plain', str);
|
||||
Services.clipboard.setData(transferable, null, Ci.nsIClipboard.kGlobalClipboard);
|
||||
let button;
|
||||
if (
|
||||
Services.zen.canShare() &&
|
||||
(currentUrl.startsWith('http://') || currentUrl.startsWith('https://'))
|
||||
) {
|
||||
button = {
|
||||
id: 'zen-copy-current-url-button',
|
||||
command: (event) => {
|
||||
const buttonRect = event.target.getBoundingClientRect();
|
||||
Services.zen.share(
|
||||
Services.io.newURI(currentUrl),
|
||||
'',
|
||||
'',
|
||||
buttonRect.left,
|
||||
window.innerHeight - buttonRect.bottom,
|
||||
buttonRect.width,
|
||||
buttonRect.height
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
gZenUIManager.showToast('zen-copy-current-url-confirmation', { button, timeout: 3000 });
|
||||
const [currentUrl, ClipboardHelper] = gURLBar.zenStrippedURI;
|
||||
const displaySpec = currentUrl.displaySpec;
|
||||
ClipboardHelper.copyString(displaySpec);
|
||||
let button;
|
||||
if (Services.zen.canShare() && displaySpec.startsWith('http')) {
|
||||
button = {
|
||||
id: 'zen-copy-current-url-button',
|
||||
command: (event) => {
|
||||
const buttonRect = event.target.getBoundingClientRect();
|
||||
Services.zen.share(
|
||||
currentUrl,
|
||||
'',
|
||||
'',
|
||||
buttonRect.left,
|
||||
window.innerHeight - buttonRect.bottom,
|
||||
buttonRect.width,
|
||||
buttonRect.height
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
gZenUIManager.showToast('zen-copy-current-url-confirmation', { button, timeout: 3000 });
|
||||
},
|
||||
|
||||
copyCurrentURLAsMarkdownToClipboard() {
|
||||
const currentUrl = gBrowser.currentURI.spec;
|
||||
const [currentUrl, ClipboardHelper] = gURLBar.zenStrippedURI;
|
||||
const tabTitle = gBrowser.selectedTab.label;
|
||||
if (currentUrl && tabTitle) {
|
||||
const markdownLink = `[${tabTitle}](${currentUrl})`;
|
||||
let str = Cc['@mozilla.org/supports-string;1'].createInstance(Ci.nsISupportsString);
|
||||
str.data = markdownLink;
|
||||
let transferable = Cc['@mozilla.org/widget/transferable;1'].createInstance(
|
||||
Ci.nsITransferable
|
||||
);
|
||||
transferable.init(window.docShell.QueryInterface(Ci.nsILoadContext));
|
||||
transferable.addDataFlavor('text/plain');
|
||||
transferable.setTransferData('text/plain', str);
|
||||
Services.clipboard.setData(transferable, null, Ci.nsIClipboard.kGlobalClipboard);
|
||||
gZenUIManager.showToast('zen-copy-current-url-confirmation');
|
||||
}
|
||||
const markdownLink = `[${tabTitle}](${currentUrl.displaySpec})`;
|
||||
ClipboardHelper.copyString(markdownLink);
|
||||
gZenUIManager.showToast('zen-copy-current-url-confirmation', { timeout: 3000 });
|
||||
},
|
||||
|
||||
throttle(f, delay) {
|
||||
|
||||
@@ -336,6 +336,10 @@
|
||||
#zen-appcontent-navbar-wrapper #zen-sidebar-top-buttons {
|
||||
max-width: fit-content;
|
||||
:root[zen-right-side='true'] & {
|
||||
order: 999;
|
||||
order: 1;
|
||||
}
|
||||
}
|
||||
|
||||
:root[zen-right-side='true'] #zen-appcontent-navbar-wrapper #PanelUI-button {
|
||||
order: 2;
|
||||
}
|
||||
|
||||
@@ -116,6 +116,9 @@
|
||||
|
||||
& #zen-sidebar-top-buttons {
|
||||
margin: var(--zen-toolbox-padding) 0 calc(var(--zen-toolbox-padding) / 2) 0;
|
||||
:root[zen-right-side='true']:not([zen-window-buttons-reversed='true']) & {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
& #PanelUI-menu-button {
|
||||
|
||||
@@ -337,7 +337,7 @@ export class nsZenSiteDataPanel {
|
||||
}
|
||||
|
||||
separator.hidden = !settingElements.length || !crossSiteCookieElements.length;
|
||||
section.hidden = list.childElementCount == 0;
|
||||
section.hidden = list.childElementCount < 2; // only the separator
|
||||
}
|
||||
|
||||
#getPermissionStateLabelId(permission) {
|
||||
|
||||
Reference in New Issue
Block a user