aboutsummaryrefslogtreecommitdiff
path: root/src/content
diff options
context:
space:
mode:
Diffstat (limited to 'src/content')
-rw-r--r--src/content/actions/operation.js8
-rw-r--r--src/content/console-frames.js7
-rw-r--r--src/content/index.js2
-rw-r--r--src/content/urls.js15
4 files changed, 30 insertions, 2 deletions
diff --git a/src/content/actions/operation.js b/src/content/actions/operation.js
index d188a60..0d5088b 100644
--- a/src/content/actions/operation.js
+++ b/src/content/actions/operation.js
@@ -2,7 +2,9 @@ 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';
+import * as consoleFrames from 'content/console-frames';
const exec = (operation) => {
switch (operation.type) {
@@ -32,6 +34,12 @@ const exec = (operation) => {
return navigates.parent(window);
case operations.NAVIGATE_ROOT:
return navigates.root(window);
+ case operations.URLS_YANK:
+ urls.yank(window);
+ return consoleFrames.postMessage(window.document, {
+ type: messages.CONSOLE_SHOW_INFO,
+ text: 'Current url yanked',
+ });
default:
browser.runtime.sendMessage({
type: messages.BACKGROUND_OPERATION,
diff --git a/src/content/console-frames.js b/src/content/console-frames.js
index 3f06466..35b975f 100644
--- a/src/content/console-frames.js
+++ b/src/content/console-frames.js
@@ -15,4 +15,9 @@ const blur = (doc) => {
iframe.blur();
};
-export { initialize, blur };
+const postMessage = (doc, message) => {
+ let iframe = doc.getElementById('vimvixen-console-frame');
+ iframe.contentWindow.postMessage(JSON.stringify(message), '*');
+};
+
+export { initialize, blur, postMessage };
diff --git a/src/content/index.js b/src/content/index.js
index adea871..63bbf77 100644
--- a/src/content/index.js
+++ b/src/content/index.js
@@ -40,7 +40,7 @@ const reloadSettings = () => {
browser.runtime.onMessage.addListener((action) => {
switch (action.type) {
- case messages.CONSOLE_HIDE:
+ case messages.CONSOLE_HIDE_COMMAND:
window.focus();
consoleFrames.blur(window.document);
return Promise.resolve();
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 };