yank a URL
This commit is contained in:
parent
bbf90e77e9
commit
f6996a2274
4 changed files with 23 additions and 1 deletions
|
@ -2,6 +2,7 @@ import operations from 'shared/operations';
|
||||||
import messages from 'shared/messages';
|
import messages from 'shared/messages';
|
||||||
import * as scrolls from 'content/scrolls';
|
import * as scrolls from 'content/scrolls';
|
||||||
import * as navigates from 'content/navigates';
|
import * as navigates from 'content/navigates';
|
||||||
|
import * as urls from 'content/urls';
|
||||||
import * as followActions from 'content/actions/follow';
|
import * as followActions from 'content/actions/follow';
|
||||||
|
|
||||||
const exec = (operation) => {
|
const exec = (operation) => {
|
||||||
|
@ -32,6 +33,8 @@ const exec = (operation) => {
|
||||||
return navigates.parent(window);
|
return navigates.parent(window);
|
||||||
case operations.NAVIGATE_ROOT:
|
case operations.NAVIGATE_ROOT:
|
||||||
return navigates.root(window);
|
return navigates.root(window);
|
||||||
|
case operations.URLS_YANK:
|
||||||
|
return urls.yank(window);
|
||||||
default:
|
default:
|
||||||
browser.runtime.sendMessage({
|
browser.runtime.sendMessage({
|
||||||
type: messages.BACKGROUND_OPERATION,
|
type: messages.BACKGROUND_OPERATION,
|
||||||
|
|
15
src/content/urls.js
Normal file
15
src/content/urls.js
Normal file
|
@ -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 };
|
|
@ -37,7 +37,8 @@ export default {
|
||||||
"[[": { "type": "navigate.link.prev" },
|
"[[": { "type": "navigate.link.prev" },
|
||||||
"]]": { "type": "navigate.link.next" },
|
"]]": { "type": "navigate.link.next" },
|
||||||
"gu": { "type": "navigate.parent" },
|
"gu": { "type": "navigate.parent" },
|
||||||
"gU": { "type": "navigate.root" }
|
"gU": { "type": "navigate.root" },
|
||||||
|
"y": { "type": "urls.yank" }
|
||||||
},
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"default": "google",
|
"default": "google",
|
||||||
|
|
|
@ -36,4 +36,7 @@ export default {
|
||||||
ZOOM_IN: 'zoom.in',
|
ZOOM_IN: 'zoom.in',
|
||||||
ZOOM_OUT: 'zoom.out',
|
ZOOM_OUT: 'zoom.out',
|
||||||
ZOOM_NEUTRAL: 'zoom.neutral',
|
ZOOM_NEUTRAL: 'zoom.neutral',
|
||||||
|
|
||||||
|
// Url yank
|
||||||
|
URLS_YANK: 'urls.yank',
|
||||||
};
|
};
|
||||||
|
|
Reference in a new issue