Skip to content

Commit

Permalink
added Toggle Reader Mode command (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbendebiene committed May 4, 2020
1 parent 4d4486b commit ac57962
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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."
Expand Down
6 changes: 6 additions & 0 deletions src/core/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
4 changes: 4 additions & 0 deletions src/resources/json/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
"permissions": ["tabs", "bookmarks"],
"group": "toggle"
},
{
"command": "ToggleReaderMode",
"group": "toggle"
},
{
"command": "ScrollTop",
"settings": {
Expand Down

0 comments on commit ac57962

Please sign in to comment.