rNeomy / reader-view

Access Firefox's built in reader view from right click context menu
https://webextension.org/listing/chrome-reader-view.html
Mozilla Public License 2.0
482 stars 75 forks source link

[Feature Request] Make chapters plugin buttons available in sidebar / for shortcuts. #202

Closed adjmunro closed 3 weeks ago

adjmunro commented 3 weeks ago

Hi! I really like what you did with your chapters plugin.

I currently have this in user actions: (which I wrote before the chapters plugin to get similar functionilty)

[
  {
    "code": "var url = 'https://' + document.getElementById('reader-domain').textContent.replace(/\\s+/g, ''); var parts = url.split('/'); var i = parts.length - 2; var index = parts[i].match(/\\d+/g); if (index != null) { index = index.map(Number)[0]; parts[i] = parts[i].replace(index, index + 1); var next = parts.join('/'); window.open(next, '_self').focus(); }",
    "shortcut": "Shift + ArrowRight",
    "title": "Next"
  },
  {
    "code": "var url = 'https://' + document.getElementById('reader-domain').textContent.replace(/\\s+/g, ''); var parts = url.split('/'); var i = parts.length - 2; var index = parts[i].match(/\\d+/g); if (index != null) { index = index.map(Number)[0]; parts[i] = parts[i].replace(index, index - 1); var next = parts.join('/'); window.open(next, '_self').focus(); }",
    "shortcut": "Shift + ArrowLeft",
    "title": "Previous"
  }
]

but to be quite frank, your chapters plugin/regex works much better than my hack. Javascript just isn't my forte.

But my only complaint is that the next/previous chapter links always show at the bottom of the page! This is bad when:

Personally, I use my custom shift + right shortcut to go to the next chapter while the TTS is still running, rather than waiting for the TTS to finish reading prev/next and also slowly moving my mouse over; and then immediate use a shift + '/' shortcut to start TTS on the next chapter.

So, please make article.next / article.previous public so that I can trigger them from one of those custom user actions (or add them to the sidebar yourself as possible buttons to display and/or add shortcuts?) 🥺

Sorry, I'd submit a PR myself, but I'm from Java/Kotlin land and can barely make heads or tails of what's going on 🙃

rNeomy commented 3 weeks ago

You can already trigger the native ones from the custom action:

[
  {
    "code": "document.querySelector('#chapters a:first-of-type').click()",
    "title": "Previous Chapter"
  },
  {
    "code": "document.querySelector('#chapters a:last-of-type').click()",
    "title": "Next Chapter"
  }
]
adjmunro commented 3 weeks ago

@rNeomy Thanks for the quick response! It works really well!