From 429d77f5105407370b63924113330d3e7ef4b6df Mon Sep 17 00:00:00 2001 From: "Michael B." Date: Sat, 4 Nov 2023 19:03:54 +0100 Subject: [PATCH 1/3] feat: copy URL of focus This works on list-based pages such as "All", "Videos", "News", etc. It doesn't work for the "Image" page. --- src/main.js | 13 +++++++++++++ src/options.js | 1 + src/options_page.html | 4 ++++ src/options_page.js | 1 + 4 files changed, 19 insertions(+) diff --git a/src/main.js b/src/main.js index e955a77d..00be764b 100644 --- a/src/main.js +++ b/src/main.js @@ -586,6 +586,19 @@ class WebSearchNavigator { }); return false; }); + this.register(getOpt('copyUrlKey'), () => { + const link = this.resultsManager.getElementToNavigate(); + if ( + link == null || link.localName !== 'a' || !link.href || + !navigator.clipboard + ) { + return true; + } + navigator.clipboard.writeText(link.href).then( + () => false, + (err) => true, + ); + }); } initChangeToolsNavigation() { diff --git a/src/options.js b/src/options.js index b0db4cdd..c7c887bf 100644 --- a/src/options.js +++ b/src/options.js @@ -152,6 +152,7 @@ const DEFAULT_KEYBINDINGS = { showImagesLarge: ['z l'], showImagesMedium: ['z e'], showImagesIcon: ['z i'], + copyUrlKey: ['c', 'y'], }; const DEFAULT_OPTIONS = { diff --git a/src/options_page.html b/src/options_page.html index 76d3ee7b..ec6c6f92 100644 --- a/src/options_page.html +++ b/src/options_page.html @@ -101,6 +101,10 @@

Keybindings

+
+ + +

Results filtering

diff --git a/src/options_page.js b/src/options_page.js index a82acdd3..b35290e5 100644 --- a/src/options_page.js +++ b/src/options_page.js @@ -103,6 +103,7 @@ const KEYBINDING_TO_DIV = { showImagesLarge: 'show-images-large', showImagesMedium: 'show-images-medium', showImagesIcon: 'show-images-icon', + copyUrlKey: 'copy-url-key', }; /** From 3b4d28d43a1137680282668c9f993823d35214da Mon Sep 17 00:00:00 2001 From: "Michael B." Date: Sun, 5 Nov 2023 14:10:07 +0100 Subject: [PATCH 2/3] feat: no default keybinding for `copyUrlKey` --- src/options.js | 2 +- src/options_page.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/options.js b/src/options.js index c7c887bf..999a1d3b 100644 --- a/src/options.js +++ b/src/options.js @@ -152,7 +152,7 @@ const DEFAULT_KEYBINDINGS = { showImagesLarge: ['z l'], showImagesMedium: ['z e'], showImagesIcon: ['z i'], - copyUrlKey: ['c', 'y'], + copyUrlKey: [], }; const DEFAULT_OPTIONS = { diff --git a/src/options_page.html b/src/options_page.html index ec6c6f92..764b202a 100644 --- a/src/options_page.html +++ b/src/options_page.html @@ -103,7 +103,7 @@

Keybindings

- +
From c8dd6a73564b8291020d76e9e04364c92377fe1c Mon Sep 17 00:00:00 2001 From: "Michael B." Date: Mon, 6 Nov 2023 14:52:16 +0100 Subject: [PATCH 3/3] fix: eslint indent error --- src/main.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.js b/src/main.js index 00be764b..6591cddb 100644 --- a/src/main.js +++ b/src/main.js @@ -595,8 +595,8 @@ class WebSearchNavigator { return true; } navigator.clipboard.writeText(link.href).then( - () => false, - (err) => true, + () => false, + (err) => true, ); }); }