Skip to content

Commit 8a27800

Browse files
committed
Update copyCurrentUrlHotkey.uc.js and some CSS.
(JS) Update copyCurrentUrlHotkey.uc.js to correctly encode/decode the URL based on user prefs. (CSS) Change the focused background for ctrlTab previews to be more visible when the screen is dark. Fix the margins of permission popups, identity popup, etc.
1 parent c078500 commit 8a27800

6 files changed

Lines changed: 71 additions & 108 deletions

File tree

JS/copyCurrentUrlHotkey.uc.js

Lines changed: 29 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// ==UserScript==
22
// @name Copy Current URL Hotkey
3-
// @version 1.2.1
3+
// @version 1.2.2
44
// @author aminomancer
55
// @homepage https://github.com/aminomancer
66
// @description Adds a new hotkey (Ctrl+Alt+C by default) that copies
@@ -14,19 +14,6 @@ class CopyCurrentURL {
1414
// hint anchored to the urlbar.
1515
"copy confirmation hint": true,
1616

17-
// when you right-click the urlbar, the context menu has a "copy" command.
18-
// set this to "true" to show a "Ctrl+Alt+C" hint next to this command, like
19-
// firefox does with many other commands. the hint text will reflect the
20-
// actual hotkey. so on macOS it will show "Cmd+Alt+C" and if you modify the
21-
// modifiers below, it will show your modifiers instead. this setting isn't
22-
// enabled by default because 1) unlike our custom hotkey, this command
23-
// actually only copies the selection, not the full input content. so it's
24-
// disabled if nothing is highlighted. and 2) the context menu is very thin
25-
// due to the short names of the commands. adding "Ctrl+Alt+C" makes it kind
26-
// of cramped. but it's easy to forget that hotkeys exist if they're not
27-
// visually displayed anywhere, so you may want to enable this feature.
28-
"context menu shortcut hint": true,
29-
3017
shortcut: {
3118
// shortcut key, combined with modifiers.
3219
key: "C",
@@ -43,6 +30,7 @@ class CopyCurrentURL {
4330
id: "key_copyCurrentUrl",
4431
},
4532
};
33+
4634
constructor() {
4735
XPCOMUtils.defineLazyServiceGetter(
4836
this,
@@ -52,60 +40,44 @@ class CopyCurrentURL {
5240
);
5341
this.hotkey = _ucUtils.registerHotkey(this.config.shortcut, win => {
5442
if (win === window) {
55-
let val = win.gURLBar._lastValidURLStr || win.gURLBar.value;
56-
if (!val) return;
43+
let val;
44+
try {
45+
let uri = win.gURLBar.makeURIReadable(win.gBrowser.currentURI);
46+
if (uri.schemeIs("javascript") || uri.schemeIs("data")) {
47+
val = win.gURLBar._lastValidURLStr || win.gURLBar.value;
48+
} else {
49+
val = uri.displaySpec;
50+
}
51+
if (win.UrlbarPrefs.get("decodeURLsOnCopy")) {
52+
val = decodeURI(val);
53+
}
54+
} catch (error) {
55+
return;
56+
}
5757
this.ClipboardHelper.copyStringToClipboard(val, this.clipboard);
5858
if (this.config["copy confirmation hint"]) {
59-
win.CustomHint?.show(win.gURLBar.inputField, "Copied", {
60-
position: "after_start",
61-
x: 16,
62-
});
59+
if (win.gURLBar.getAttribute("pageproxystate") == "valid") {
60+
win.CustomHint?.show(win.gURLBar.inputField, "Copied", {
61+
position: "after_start",
62+
x: 16,
63+
});
64+
} else {
65+
win.CustomHint?.show(
66+
win.gIdentityHandler._identityIconBox,
67+
"Copied",
68+
{ position: "bottomcenter topleft", y: 8 }
69+
);
70+
}
6371
}
6472
}
6573
});
66-
if (this.config["context menu shortcut hint"]) this.shortcutHint();
6774
}
75+
6876
get clipboard() {
6977
return Services.clipboard.supportsSelectionClipboard()
7078
? Services.clipboard.kSelectionClipboard
7179
: Services.clipboard.kGlobalClipboard;
7280
}
73-
handleEvent() {
74-
let menuitem = gURLBar.inputField?.parentElement?.menupopup?.querySelector(
75-
`[cmd="cmd_copy"]`
76-
);
77-
if (menuitem) {
78-
if (!this.hintApplied && menuitem.hasAttribute("key")) {
79-
gURLBar.removeEventListener("contextmenu", this);
80-
return;
81-
}
82-
if (
83-
gURLBar.selectionStart != 0 ||
84-
gURLBar.selectionEnd != gURLBar.inputField.textLength
85-
) {
86-
menuitem.setAttribute("key", this.config.shortcut.id);
87-
} else {
88-
menuitem.removeAttribute("key");
89-
}
90-
this.hintApplied = true;
91-
}
92-
}
93-
shortcutHint() {
94-
if (gBrowserInit.delayedStartupFinished) {
95-
gURLBar.addEventListener("contextmenu", this);
96-
} else {
97-
let delayedListener = (subject, topic) => {
98-
if (topic == "browser-delayed-startup-finished" && subject == window) {
99-
Services.obs.removeObserver(delayedListener, topic);
100-
gURLBar.addEventListener("contextmenu", this);
101-
}
102-
};
103-
Services.obs.addObserver(
104-
delayedListener,
105-
"browser-delayed-startup-finished"
106-
);
107-
}
108-
}
10981
}
11082

11183
window.copyCurrentUrl = new CopyCurrentURL();

uc-ctrl-tab.css

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
appearance: none !important;
1111
border-style: none !important;
1212
font-weight: normal !important;
13-
text-shadow: 0 0 2px hsl(0, 0%, 8%), 0 0 2px hsl(0, 0%, 8%) !important;
1413
box-shadow: none !important;
1514
background: none !important;
1615
--panel-background: var(--ctrlTab-overlay-color) !important;
@@ -67,12 +66,6 @@
6766
padding: 2px 4px !important;
6867
}
6968

70-
#ctrlTab-showAll:focus,
71-
#ctrlTab-showAll:focus-within {
72-
background-color: var(--ctrlTab-panel-focused-bgcolor) !important;
73-
border-color: var(--attention-color) !important;
74-
}
75-
7669
.ctrlTab-preview-inner {
7770
flex: 0 !important;
7871
color: var(--ui-text-80) !important;
@@ -84,10 +77,18 @@
8477
background-color: var(--ctrlTab-panel-bgcolor) !important;
8578
}
8679

80+
#ctrlTab-showAll:focus,
81+
#ctrlTab-showAll:focus-within,
8782
.ctrlTab-preview:focus > .ctrlTab-preview-inner {
8883
background-color: var(--ctrlTab-panel-focused-bgcolor) !important;
89-
border-color: var(--attention-color) !important;
90-
box-shadow: 0 0 4px -1px rgba(0, 0, 0, 0.2), 0 0 25px -2px rgba(0, 0, 0, 0.2), inset 0 0 20px 5px hsla(0, 0%, 0%, 0.5) !important;
84+
border-color: transparent !important;
85+
outline: 4px solid var(--ctrlTab-panel-focused-bgcolor) !important;
86+
outline-offset: -2px !important;
87+
text-shadow: 0 0 1px hsla(0, 0%, 0%, 1), 0 0 2px hsla(0, 0%, 0%, 0.75), 0 0 4px hsla(0, 0%, 0%, 0.5) !important;
88+
}
89+
90+
.ctrlTab-preview:focus > .ctrlTab-preview-inner > .ctrlTab-canvas {
91+
box-shadow: 0 0 4px hsla(0, 0%, 0%, 0.25), 0 0 6px hsla(0, 0%, 0%, 0.125), 0 0 8px hsla(0, 0%, 0%, 0.125) !important;
9192
}
9293

9394
.ctrlTab-canvas > * {

uc-globals.css

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,17 @@ but other than that these variables should be available everywhere. */
337337
hsla(var(--download-button-hue), 90%, 76.94%, 0.01) 96.3%
338338
); */
339339

340-
--pink-action: hsl(340, 73%, 58%);
340+
--ctrlTab-overlay-color: hsla(240, 3%, 4%, 0.5);
341+
--ctrlTab-panel-disabled-bgcolor: hsla(240, 2%, 9%, 0.8);
342+
--ctrlTab-panel-disabled-focused-bgcolor: hsla(240, 8%, 3%, 0.9);
343+
--ctrlTab-panel-bgcolor: hsla(240, 3%, 4%, 0.9);
344+
--ctrlTab-panel-focused-bgcolor: var(--indigo-45);
345+
346+
--indigo-30: hsl(230, 87%, 70%);
347+
--indigo-40: hsl(232, 82%, 60%);
348+
--indigo-45: hsl(233, 72%, 55%);
349+
--indigo-50: hsl(234, 62%, 50%);
350+
341351
--purple-20: hsl(240, 100%, 80%);
342352
--purple-25: hsl(240, 100%, 75%);
343353
--purple-30: hsl(239, 100%, 70%);
@@ -354,9 +364,11 @@ but other than that these variables should be available everywhere. */
354364
--purple-60: hsl(258, 95%, 40%) !important;
355365
--purple-70: hsl(256, 97%, 30%);
356366
--purple-80: hsl(254, 100%, 20%);
367+
357368
--pink-40: hsl(340, 73%, 60%);
358369
--pink-35: hsl(340, 73%, 65%);
359370
--pink-30: hsl(340, 73%, 70%);
371+
--pink-action: hsl(340, 73%, 58%);
360372

361373
--uc-parent-page-color: hsl(212, 43%, 90%);
362374
--uc-parent-link-color: var(--purple-35);

uc-panels.css

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -823,12 +823,7 @@ popupnotificationcontent label[control]:not([hidden]) + menulist {
823823
}
824824

825825
#permission-popup-permissions-content {
826-
padding: 4px 8px 2px 8px !important;
827-
}
828-
829-
.permission-popup-permission-item,
830-
#permission-popup-storage-access-permission-list-header {
831-
margin-block: 0.25em;
826+
padding: 8px 8px 2px 8px !important;
832827
}
833828

834829
.permission-popup-permission-label,
@@ -841,8 +836,13 @@ popupnotificationcontent label[control]:not([hidden]) + menulist {
841836
margin-top: 4px !important;
842837
}
843838

844-
.permission-popup-permission-list-anchor[anchorfor="3rdPartyStorage"] > vbox + .permission-popup-permission-item {
845-
margin-top: 0 !important;
839+
.permission-popup-permission-item {
840+
min-height: revert !important;
841+
}
842+
843+
.permission-popup-permission-item,
844+
#permission-popup-storage-access-permission-list-header {
845+
margin-block: 0 4px !important;
846846
}
847847

848848
.permission-popup-section menulist {

uc-popups.css

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -772,27 +772,7 @@ rtl languages. adjust the border radius accordingly */
772772
-moz-box-pack: center;
773773
}
774774

775-
@-moz-document url("chrome://global/content/commonDialog.xhtml"),
776-
url("chrome://mozapps/content/handling/permissionDialog.xhtml"),
777-
url("chrome://mozapps/content/handling/appChooser.xhtml"),
778-
url("chrome://global/content/appPicker.xhtml"),
779-
url("chrome://mozapps/content/downloads/unknownContentType.xhtml"),
780-
url-prefix("chrome://browser/content/sanitize.xhtml") {
781-
/* use this selector to exclude null-window prompts, which open in their own
782-
windows and don't inherit styles from the chrome window. we don't want to
783-
apply theme styles to these prompts because no matter what we do, we can't
784-
control the titlebar. it'll always be white with a red button on windows,
785-
without OS-level intervention. so don't bother with them. we just use scripts
786-
to try to make all dialogs open as either modal dialogs which attach to
787-
existing chrome windows or browsing contexts, or as windowed dialogs with the
788-
titlebars hidden. that can only happen at the programming level, in javascript
789-
or C++. we can't do anything about the prompts opened by C++ so we just have
790-
to hope mozilla gets rid of them, but fortunately mozilla has caught on and is
791-
gradually converting these dialogs to modals which pass the window or browsing
792-
context as the first parameter. e.g. try submitting this in console:
793-
Services.prompt.confirmEx(window, "title", "text", 1, "1", "2", "3", "checkbox", {value: false})
794-
then try changing the first parameter window to null and you'll see it opens
795-
as a regular null-window dialog instead. */
775+
@-moz-document url("chrome://global/content/commonDialog.xhtml"), url("chrome://mozapps/content/handling/permissionDialog.xhtml"), url("chrome://mozapps/content/handling/appChooser.xhtml"), url("chrome://global/content/appPicker.xhtml"), url("chrome://mozapps/content/downloads/unknownContentType.xhtml"), url-prefix("chrome://browser/content/sanitize.xhtml") {
796776
#commonDialogWindow[dialogroot],
797777
#commonDialogWindow[dialogroot] *,
798778
.dialog-button-box {
@@ -843,18 +823,18 @@ rtl languages. adjust the border radius accordingly */
843823
margin-block-start: 2px !important;
844824
}
845825

846-
.dialog-content-box:not([hidden]) + .dialog-button-box {
826+
:is(.dialog-content-box, [part="content-box"]):not([hidden]) + .dialog-button-box {
847827
margin-top: 5px;
848828
}
849829

850830
.dialog-button-box:not([hidden]) {
851-
display: flex;
852-
justify-content: end;
831+
-moz-box-layout: flex;
832+
-moz-box-pack: end;
833+
margin-inline: 4px;
853834
}
854835

855836
.dialog-button-box > button {
856-
flex-grow: 0.15;
857-
flex-wrap: nowrap;
837+
-moz-box-flex: 0.15;
858838
}
859839

860840
.dialog-button-box > button {
@@ -1072,8 +1052,7 @@ rtl languages. adjust the border radius accordingly */
10721052
}
10731053
}
10741054

1075-
@-moz-document url("chrome://mozapps/content/downloads/unknownContentType.xhtml"),
1076-
url("chrome://global/content/appPicker.xhtml") {
1055+
@-moz-document url("chrome://mozapps/content/downloads/unknownContentType.xhtml"), url("chrome://global/content/appPicker.xhtml") {
10771056
:root,
10781057
:root dialog,
10791058
.dialog-button-box {
@@ -1107,6 +1086,10 @@ rtl languages. adjust the border radius accordingly */
11071086
--in-content-table-header-background: var(--purple-40-a50) !important;
11081087
}
11091088

1089+
:root {
1090+
max-width: 36em;
1091+
}
1092+
11101093
#unknownContentType {
11111094
padding: 10px !important;
11121095
}

uc-variables.css

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,6 @@ menupopup {
107107
--downloads-item-font-size-factor: 0.9;
108108
--downloads-item-details-opacity: 0.6;
109109
--downloads-item-disabled-opacity: 0.6;
110-
--ctrlTab-overlay-color: hsla(240, 3%, 4%, 0.5) !important;
111-
--ctrlTab-panel-disabled-bgcolor: hsla(240, 2%, 9%, 0.8) !important;
112-
--ctrlTab-panel-disabled-focused-bgcolor: hsla(240, 8%, 3%, 0.9) !important;
113-
--ctrlTab-panel-bgcolor: hsla(240, 3%, 4%, 0.9) !important;
114-
--ctrlTab-panel-focused-bgcolor: hsla(10, 12%, 2%, 0.99) !important;
115110
--in-content-box-background: hsl(232, 32%, 14%) !important;
116111
--in-content-box-border-color: rgba(249, 249, 250, 0.1) !important;
117112
--in-content-button-background: var(--arrowpanel-dimmed) !important;

0 commit comments

Comments
 (0)