From ac5796290e99204d37a38bf26bb27fc9fdbac2c0 Mon Sep 17 00:00:00 2001 From: Robbendebiene Date: Mon, 4 May 2020 11:02:59 +0200 Subject: [PATCH] added Toggle Reader Mode command (#351) --- src/_locales/en/messages.json | 8 ++++++++ src/core/commands.js | 6 ++++++ src/resources/json/commands.json | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index 091616938..f3d76c181 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -389,6 +389,10 @@ "message": "Toggle mute", "description": "Toggle mute" }, + "commandLabelToggleReaderMode": { + "message": "Toggle reader mode", + "description": "Toggle reader mode" + }, "commandLabelScrollTop": { "message": "Scroll to the top", "description": "Scroll to the top" @@ -694,6 +698,10 @@ "message": "Mutes or unmutes the current tab.", "description": "Mutes or unmutes the current tab." }, + "commandDescriptionToggleReaderMode": { + "message": "Activates or deactivates the reader view if available.", + "description": "Activates or deactivates the reader view if available." + }, "commandDescriptionScrollTop": { "message": "Scrolls to the top of the page.", "description": "Scrolls to the top of the page." diff --git a/src/core/commands.js b/src/core/commands.js index bf2a70f1c..8d41be06b 100644 --- a/src/core/commands.js +++ b/src/core/commands.js @@ -263,6 +263,12 @@ export function ToggleBookmark (sender, data) { } +// reverts the action if already pinned +export function ToggleReaderMode (sender, data) { + browser.tabs.toggleReaderMode(sender.tab.id); +} + + export function ScrollTop (sender, data) { // returns true if there exist a scrollable element in the injected frame else false const runScroll = browser.tabs.executeScript(sender.tab.id, { diff --git a/src/resources/json/commands.json b/src/resources/json/commands.json index 4a0a74376..409638417 100644 --- a/src/resources/json/commands.json +++ b/src/resources/json/commands.json @@ -99,6 +99,10 @@ "permissions": ["tabs", "bookmarks"], "group": "toggle" }, + { + "command": "ToggleReaderMode", + "group": "toggle" + }, { "command": "ScrollTop", "settings": {