diff --git a/JS/copyCurrentUrlHotkey.uc.js b/JS/copyCurrentUrlHotkey.uc.js index 8f566d1..d7a1d6c 100644 --- a/JS/copyCurrentUrlHotkey.uc.js +++ b/JS/copyCurrentUrlHotkey.uc.js @@ -1,6 +1,6 @@ // ==UserScript== // @name Copy Current URL Hotkey -// @version 1.2.1 +// @version 1.2.2 // @author aminomancer // @homepage https://github.com/aminomancer // @description Adds a new hotkey (Ctrl+Alt+C by default) that copies @@ -14,19 +14,6 @@ class CopyCurrentURL { // hint anchored to the urlbar. "copy confirmation hint": true, - // when you right-click the urlbar, the context menu has a "copy" command. - // set this to "true" to show a "Ctrl+Alt+C" hint next to this command, like - // firefox does with many other commands. the hint text will reflect the - // actual hotkey. so on macOS it will show "Cmd+Alt+C" and if you modify the - // modifiers below, it will show your modifiers instead. this setting isn't - // enabled by default because 1) unlike our custom hotkey, this command - // actually only copies the selection, not the full input content. so it's - // disabled if nothing is highlighted. and 2) the context menu is very thin - // due to the short names of the commands. adding "Ctrl+Alt+C" makes it kind - // of cramped. but it's easy to forget that hotkeys exist if they're not - // visually displayed anywhere, so you may want to enable this feature. - "context menu shortcut hint": true, - shortcut: { // shortcut key, combined with modifiers. key: "C", @@ -43,6 +30,7 @@ class CopyCurrentURL { id: "key_copyCurrentUrl", }, }; + constructor() { XPCOMUtils.defineLazyServiceGetter( this, @@ -52,60 +40,44 @@ class CopyCurrentURL { ); this.hotkey = _ucUtils.registerHotkey(this.config.shortcut, win => { if (win === window) { - let val = win.gURLBar._lastValidURLStr || win.gURLBar.value; - if (!val) return; + let val; + try { + let uri = win.gURLBar.makeURIReadable(win.gBrowser.currentURI); + if (uri.schemeIs("javascript") || uri.schemeIs("data")) { + val = win.gURLBar._lastValidURLStr || win.gURLBar.value; + } else { + val = uri.displaySpec; + } + if (win.UrlbarPrefs.get("decodeURLsOnCopy")) { + val = decodeURI(val); + } + } catch (error) { + return; + } this.ClipboardHelper.copyStringToClipboard(val, this.clipboard); if (this.config["copy confirmation hint"]) { - win.CustomHint?.show(win.gURLBar.inputField, "Copied", { - position: "after_start", - x: 16, - }); + if (win.gURLBar.getAttribute("pageproxystate") == "valid") { + win.CustomHint?.show(win.gURLBar.inputField, "Copied", { + position: "after_start", + x: 16, + }); + } else { + win.CustomHint?.show( + win.gIdentityHandler._identityIconBox, + "Copied", + { position: "bottomcenter topleft", y: 8 } + ); + } } } }); - if (this.config["context menu shortcut hint"]) this.shortcutHint(); } + get clipboard() { return Services.clipboard.supportsSelectionClipboard() ? Services.clipboard.kSelectionClipboard : Services.clipboard.kGlobalClipboard; } - handleEvent() { - let menuitem = gURLBar.inputField?.parentElement?.menupopup?.querySelector( - `[cmd="cmd_copy"]` - ); - if (menuitem) { - if (!this.hintApplied && menuitem.hasAttribute("key")) { - gURLBar.removeEventListener("contextmenu", this); - return; - } - if ( - gURLBar.selectionStart != 0 || - gURLBar.selectionEnd != gURLBar.inputField.textLength - ) { - menuitem.setAttribute("key", this.config.shortcut.id); - } else { - menuitem.removeAttribute("key"); - } - this.hintApplied = true; - } - } - shortcutHint() { - if (gBrowserInit.delayedStartupFinished) { - gURLBar.addEventListener("contextmenu", this); - } else { - let delayedListener = (subject, topic) => { - if (topic == "browser-delayed-startup-finished" && subject == window) { - Services.obs.removeObserver(delayedListener, topic); - gURLBar.addEventListener("contextmenu", this); - } - }; - Services.obs.addObserver( - delayedListener, - "browser-delayed-startup-finished" - ); - } - } } window.copyCurrentUrl = new CopyCurrentURL(); diff --git a/uc-ctrl-tab.css b/uc-ctrl-tab.css index ed94396..9f6d8be 100644 --- a/uc-ctrl-tab.css +++ b/uc-ctrl-tab.css @@ -10,7 +10,6 @@ appearance: none !important; border-style: none !important; font-weight: normal !important; - text-shadow: 0 0 2px hsl(0, 0%, 8%), 0 0 2px hsl(0, 0%, 8%) !important; box-shadow: none !important; background: none !important; --panel-background: var(--ctrlTab-overlay-color) !important; @@ -67,12 +66,6 @@ padding: 2px 4px !important; } -#ctrlTab-showAll:focus, -#ctrlTab-showAll:focus-within { - background-color: var(--ctrlTab-panel-focused-bgcolor) !important; - border-color: var(--attention-color) !important; -} - .ctrlTab-preview-inner { flex: 0 !important; color: var(--ui-text-80) !important; @@ -84,10 +77,18 @@ background-color: var(--ctrlTab-panel-bgcolor) !important; } +#ctrlTab-showAll:focus, +#ctrlTab-showAll:focus-within, .ctrlTab-preview:focus > .ctrlTab-preview-inner { background-color: var(--ctrlTab-panel-focused-bgcolor) !important; - border-color: var(--attention-color) !important; - 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; + border-color: transparent !important; + outline: 4px solid var(--ctrlTab-panel-focused-bgcolor) !important; + outline-offset: -2px !important; + 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; +} + +.ctrlTab-preview:focus > .ctrlTab-preview-inner > .ctrlTab-canvas { + 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; } .ctrlTab-canvas > * { diff --git a/uc-globals.css b/uc-globals.css index e846c7b..1fef458 100644 --- a/uc-globals.css +++ b/uc-globals.css @@ -337,7 +337,17 @@ but other than that these variables should be available everywhere. */ hsla(var(--download-button-hue), 90%, 76.94%, 0.01) 96.3% ); */ - --pink-action: hsl(340, 73%, 58%); + --ctrlTab-overlay-color: hsla(240, 3%, 4%, 0.5); + --ctrlTab-panel-disabled-bgcolor: hsla(240, 2%, 9%, 0.8); + --ctrlTab-panel-disabled-focused-bgcolor: hsla(240, 8%, 3%, 0.9); + --ctrlTab-panel-bgcolor: hsla(240, 3%, 4%, 0.9); + --ctrlTab-panel-focused-bgcolor: var(--indigo-45); + + --indigo-30: hsl(230, 87%, 70%); + --indigo-40: hsl(232, 82%, 60%); + --indigo-45: hsl(233, 72%, 55%); + --indigo-50: hsl(234, 62%, 50%); + --purple-20: hsl(240, 100%, 80%); --purple-25: hsl(240, 100%, 75%); --purple-30: hsl(239, 100%, 70%); @@ -354,9 +364,11 @@ but other than that these variables should be available everywhere. */ --purple-60: hsl(258, 95%, 40%) !important; --purple-70: hsl(256, 97%, 30%); --purple-80: hsl(254, 100%, 20%); + --pink-40: hsl(340, 73%, 60%); --pink-35: hsl(340, 73%, 65%); --pink-30: hsl(340, 73%, 70%); + --pink-action: hsl(340, 73%, 58%); --uc-parent-page-color: hsl(212, 43%, 90%); --uc-parent-link-color: var(--purple-35); diff --git a/uc-panels.css b/uc-panels.css index 41253c5..e5ec2a5 100644 --- a/uc-panels.css +++ b/uc-panels.css @@ -823,12 +823,7 @@ popupnotificationcontent label[control]:not([hidden]) + menulist { } #permission-popup-permissions-content { - padding: 4px 8px 2px 8px !important; -} - -.permission-popup-permission-item, -#permission-popup-storage-access-permission-list-header { - margin-block: 0.25em; + padding: 8px 8px 2px 8px !important; } .permission-popup-permission-label, @@ -841,8 +836,13 @@ popupnotificationcontent label[control]:not([hidden]) + menulist { margin-top: 4px !important; } -.permission-popup-permission-list-anchor[anchorfor="3rdPartyStorage"] > vbox + .permission-popup-permission-item { - margin-top: 0 !important; +.permission-popup-permission-item { + min-height: revert !important; +} + +.permission-popup-permission-item, +#permission-popup-storage-access-permission-list-header { + margin-block: 0 4px !important; } .permission-popup-section menulist { diff --git a/uc-popups.css b/uc-popups.css index d014991..d6ae817 100644 --- a/uc-popups.css +++ b/uc-popups.css @@ -772,27 +772,7 @@ rtl languages. adjust the border radius accordingly */ -moz-box-pack: center; } -@-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") { - /* use this selector to exclude null-window prompts, which open in their own - windows and don't inherit styles from the chrome window. we don't want to - apply theme styles to these prompts because no matter what we do, we can't - control the titlebar. it'll always be white with a red button on windows, - without OS-level intervention. so don't bother with them. we just use scripts - to try to make all dialogs open as either modal dialogs which attach to - existing chrome windows or browsing contexts, or as windowed dialogs with the - titlebars hidden. that can only happen at the programming level, in javascript - or C++. we can't do anything about the prompts opened by C++ so we just have - to hope mozilla gets rid of them, but fortunately mozilla has caught on and is - gradually converting these dialogs to modals which pass the window or browsing - context as the first parameter. e.g. try submitting this in console: - Services.prompt.confirmEx(window, "title", "text", 1, "1", "2", "3", "checkbox", {value: false}) - then try changing the first parameter window to null and you'll see it opens - as a regular null-window dialog instead. */ +@-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") { #commonDialogWindow[dialogroot], #commonDialogWindow[dialogroot] *, .dialog-button-box { @@ -843,18 +823,18 @@ rtl languages. adjust the border radius accordingly */ margin-block-start: 2px !important; } - .dialog-content-box:not([hidden]) + .dialog-button-box { + :is(.dialog-content-box, [part="content-box"]):not([hidden]) + .dialog-button-box { margin-top: 5px; } .dialog-button-box:not([hidden]) { - display: flex; - justify-content: end; + -moz-box-layout: flex; + -moz-box-pack: end; + margin-inline: 4px; } .dialog-button-box > button { - flex-grow: 0.15; - flex-wrap: nowrap; + -moz-box-flex: 0.15; } .dialog-button-box > button { @@ -1072,8 +1052,7 @@ rtl languages. adjust the border radius accordingly */ } } -@-moz-document url("chrome://mozapps/content/downloads/unknownContentType.xhtml"), - url("chrome://global/content/appPicker.xhtml") { +@-moz-document url("chrome://mozapps/content/downloads/unknownContentType.xhtml"), url("chrome://global/content/appPicker.xhtml") { :root, :root dialog, .dialog-button-box { @@ -1107,6 +1086,10 @@ rtl languages. adjust the border radius accordingly */ --in-content-table-header-background: var(--purple-40-a50) !important; } + :root { + max-width: 36em; + } + #unknownContentType { padding: 10px !important; } diff --git a/uc-variables.css b/uc-variables.css index c2f711b..9ef7e72 100644 --- a/uc-variables.css +++ b/uc-variables.css @@ -107,11 +107,6 @@ menupopup { --downloads-item-font-size-factor: 0.9; --downloads-item-details-opacity: 0.6; --downloads-item-disabled-opacity: 0.6; - --ctrlTab-overlay-color: hsla(240, 3%, 4%, 0.5) !important; - --ctrlTab-panel-disabled-bgcolor: hsla(240, 2%, 9%, 0.8) !important; - --ctrlTab-panel-disabled-focused-bgcolor: hsla(240, 8%, 3%, 0.9) !important; - --ctrlTab-panel-bgcolor: hsla(240, 3%, 4%, 0.9) !important; - --ctrlTab-panel-focused-bgcolor: hsla(10, 12%, 2%, 0.99) !important; --in-content-box-background: hsl(232, 32%, 14%) !important; --in-content-box-border-color: rgba(249, 249, 250, 0.1) !important; --in-content-button-background: var(--arrowpanel-dimmed) !important;