summaryrefslogtreecommitdiff
path: root/source/features/copy-on-y.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'source/features/copy-on-y.tsx')
-rw-r--r--source/features/copy-on-y.tsx21
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,
});