aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/content/actions/operation.js3
-rw-r--r--src/content/urls.js15
-rw-r--r--src/shared/default-settings.js3
-rw-r--r--src/shared/operations.js3
4 files changed, 23 insertions, 1 deletions
diff --git a/src/content/actions/operation.js b/src/content/actions/operation.js
index d188a60..0c8b0ff 100644
--- a/src/content/actions/operation.js
+++ b/src/content/actions/operation.js
@@ -2,6 +2,7 @@ import operations from 'shared/operations';
import messages from 'shared/messages';
import * as scrolls from 'content/scrolls';
import * as navigates from 'content/navigates';
+import * as urls from 'content/urls';
import * as followActions from 'content/actions/follow';
const exec = (operation) => {
@@ -32,6 +33,8 @@ const exec = (operation) => {
return navigates.parent(window);
case operations.NAVIGATE_ROOT:
return navigates.root(window);
+ case operations.URLS_YANK:
+ return urls.yank(window);
default:
browser.runtime.sendMessage({
type: messages.BACKGROUND_OPERATION,
diff --git a/src/content/urls.js b/src/content/urls.js
new file mode 100644
index 0000000..8f8a1ac
--- /dev/null
+++ b/src/content/urls.js
@@ -0,0 +1,15 @@
+const yank = (win) => {
+ let input = win.document.createElement('input');
+ win.document.body.append(input);
+
+ input.style.position = 'fixed';
+ input.style.top = '-100px';
+ input.value = win.location.href;
+ input.select();
+
+ win.document.execCommand('copy');
+
+ input.remove();
+};
+
+export { yank };
diff --git a/src/shared/default-settings.js b/src/shared/default-settings.js
index d602117..24ac536 100644
--- a/src/shared/default-settings.js
+++ b/src/shared/default-settings.js
@@ -37,7 +37,8 @@ export default {
"[[": { "type": "navigate.link.prev" },
"]]": { "type": "navigate.link.next" },
"gu": { "type": "navigate.parent" },
- "gU": { "type": "navigate.root" }
+ "gU": { "type": "navigate.root" },
+ "y": { "type": "urls.yank" }
},
"search": {
"default": "google",
diff --git a/src/shared/operations.js b/src/shared/operations.js
index 5e4a1e5..ca62716 100644
--- a/src/shared/operations.js
+++ b/src/shared/operations.js
@@ -36,4 +36,7 @@ export default {
ZOOM_IN: 'zoom.in',
ZOOM_OUT: 'zoom.out',
ZOOM_NEUTRAL: 'zoom.neutral',
+
+ // Url yank
+ URLS_YANK: 'urls.yank',
};