diff options
| author | 2023-02-01 13:16:37 +0800 | |
|---|---|---|
| committer | 2023-02-01 13:16:37 +0800 | |
| commit | aabe99973eb836e1101a17a94b7f47ee435d4d1e (patch) | |
| tree | 7a9926ea4ea326751552ae807218be70c74b370d | |
| parent | b3d565fb9011ff1c55ca866352da4078f8604d1a (diff) | |
| download | refined-github-aabe99973eb836e1101a17a94b7f47ee435d4d1e.tar.gz refined-github-aabe99973eb836e1101a17a94b7f47ee435d4d1e.tar.zst refined-github-aabe99973eb836e1101a17a94b7f47ee435d4d1e.zip | |
Restore `copy-on-y` and enable it on every page (#6252)
| -rw-r--r-- | source/features/copy-on-y.tsx | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/source/features/copy-on-y.tsx b/source/features/copy-on-y.tsx index 188a318b..6cbe6ace 100644 --- a/source/features/copy-on-y.tsx +++ b/source/features/copy-on-y.tsx @@ -1,29 +1,20 @@ -import select from 'select-dom'; -import * as pageDetect from 'github-url-detection'; - import features from '../feature-manager'; import {isEditable} from '../helpers/dom-utils'; -const handler = ({key, target}: KeyboardEvent): void => { +async function handler({key, target}: KeyboardEvent): Promise<void> { if (key === 'y' && !isEditable(target)) { - const permalink = select('a.js-permalink-shortcut')!.href; - void navigator.clipboard.writeText(permalink + location.hash); + const url = location.href; + await navigator.clipboard.writeText(url); + // Log to ensure we're coping the new URL + console.log('Copied URL to the clipboard', url); } -}; +} function init(signal: AbortSignal): void { window.addEventListener('keyup', handler, {signal}); } void features.add(import.meta.url, { - include: [ - pageDetect.isBlame, - pageDetect.isCompare, - pageDetect.isRepoTree, - pageDetect.isRepoCommitList, - pageDetect.isSingleCommit, - pageDetect.isSingleFile, - ], awaitDomReady: false, init, }); |
