diff --git a/README.md b/README.md index d77291d..bc17cf6 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Firefox by WebExtensions API. - [ ] yank/paste page - [x] pagenation - [x] open parent page + - [x] open root page - [ ] hints - [x] open a link - [ ] open a link in new tab diff --git a/src/background/keys.js b/src/background/keys.js index 992b42d..34483a0 100644 --- a/src/background/keys.js +++ b/src/background/keys.js @@ -33,6 +33,7 @@ const defaultKeymap = { '[[': { type: operations.NAVIGATE_LINK_PREV }, ']]': { type: operations.NAVIGATE_LINK_NEXT }, 'gu': { type: operations.NAVIGATE_PARENT }, + 'gU': { type: operations.NAVIGATE_ROOT }, }; const asKeymapChars = (keys) => { diff --git a/src/content/index.js b/src/content/index.js index 4751cde..a9ccd63 100644 --- a/src/content/index.js +++ b/src/content/index.js @@ -45,6 +45,8 @@ const execOperation = (operation) => { return navigates.linkNext(window); case operations.NAVIGATE_PARENT: return navigates.parent(window); + case operations.NAVIGATE_ROOT: + return navigates.root(window); } }; diff --git a/src/content/navigates.js b/src/content/navigates.js index 692b7be..64e5fc0 100644 --- a/src/content/navigates.js +++ b/src/content/navigates.js @@ -63,4 +63,8 @@ const parent = (win) => { } }; -export { historyPrev, historyNext, linkPrev, linkNext, parent }; +const root = (win) => { + win.location = win.location.origin; +}; + +export { historyPrev, historyNext, linkPrev, linkNext, parent, root }; diff --git a/src/operations/index.js b/src/operations/index.js index 493e866..a40123a 100644 --- a/src/operations/index.js +++ b/src/operations/index.js @@ -16,6 +16,7 @@ export default { NAVIGATE_LINK_PREV: 'navigate.link.prev', NAVIGATE_LINK_NEXT: 'navigate.link.next', NAVIGATE_PARENT: 'navigate.parent', + NAVIGATE_ROOT: 'navigate.root', // Background TABS_CLOSE: 'tabs.close',