From 21c28e668ef6fa6ca384f5bc67bcba1f22f26d57 Mon Sep 17 00:00:00 2001 From: emlow Date: Sun, 1 Apr 2018 16:16:29 +0100 Subject: [PATCH 1/3] shortcut to view page source --- README.md | 1 + src/background/actions/operation.js | 5 +++++ src/shared/operations.js | 3 +++ src/shared/settings/default.js | 1 + 4 files changed, 10 insertions(+) diff --git a/README.md b/README.md index f31f1e2..db69683 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,7 @@ The default mappings are as follows: - /: start to find a keyword in the page - n: find next keyword in the page - N: find prev keyword in the page +- gf: view page source ### Console commands diff --git a/src/background/actions/operation.js b/src/background/actions/operation.js index 56eb168..c477ce7 100644 --- a/src/background/actions/operation.js +++ b/src/background/actions/operation.js @@ -77,6 +77,11 @@ const exec = (operation, tab) => { return browser.tabs.sendMessage(tab.id, { type: messages.CONSOLE_HIDE, }); + case operations.PAGE_SOURCE: + return browser.tabs.create({ + url: 'view-source:' + tab.url, + index: tab.index + 1 + }); default: return Promise.resolve(); } diff --git a/src/shared/operations.js b/src/shared/operations.js index a2f980f..e8cc8cf 100644 --- a/src/shared/operations.js +++ b/src/shared/operations.js @@ -37,6 +37,9 @@ export default { // Focus FOCUS_INPUT: 'focus.input', + // Page + PAGE_SOURCE: 'page.source', + // Tabs TAB_CLOSE: 'tabs.close', TAB_CLOSE_FORCE: 'tabs.close.force', diff --git a/src/shared/settings/default.js b/src/shared/settings/default.js index 3c4dcac..f82db5a 100644 --- a/src/shared/settings/default.js +++ b/src/shared/settings/default.js @@ -46,6 +46,7 @@ export default { "gu": { "type": "navigate.parent" }, "gU": { "type": "navigate.root" }, "gi": { "type": "focus.input" }, + "gf": { "type": "page.source" }, "y": { "type": "urls.yank" }, "p": { "type": "urls.paste", "newTab": false }, "P": { "type": "urls.paste", "newTab": true }, From 740e123b36bab2a50282e73b0a20ec6863590f8f Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sat, 5 May 2018 20:43:52 +0900 Subject: [PATCH 2/3] Use openerTabId for view-source --- src/background/actions/operation.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/background/actions/operation.js b/src/background/actions/operation.js index c477ce7..10c366f 100644 --- a/src/background/actions/operation.js +++ b/src/background/actions/operation.js @@ -80,7 +80,8 @@ const exec = (operation, tab) => { case operations.PAGE_SOURCE: return browser.tabs.create({ url: 'view-source:' + tab.url, - index: tab.index + 1 + index: tab.index + 1, + openerTabId: tab.id, }); default: return Promise.resolve(); From 912231500439306f4d822e4fdc1764a7c68c5da2 Mon Sep 17 00:00:00 2001 From: Shin'ya Ueoka Date: Sat, 5 May 2018 20:48:37 +0900 Subject: [PATCH 3/3] Add page.source form --- src/settings/components/form/keymaps-form.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/settings/components/form/keymaps-form.jsx b/src/settings/components/form/keymaps-form.jsx index 0e4a223..c830d95 100644 --- a/src/settings/components/form/keymaps-form.jsx +++ b/src/settings/components/form/keymaps-form.jsx @@ -36,6 +36,7 @@ const KeyMapFields = [ ['navigate.link.prev', 'Open previous link'], ['navigate.parent', 'Go to parent directory'], ['navigate.root', 'Go to root directory'], + ['page.source', 'Open page source'], ['focus.input', 'Focus input'], ], [ ['find.start', 'Start find mode'],