vmavromatis / lemmy-keyboard-navigation Goto Github PK
View Code? Open in Web Editor NEWRES-like script that allows you to easily navigate Lemmy with your keyboard
License: GNU General Public License v3.0
RES-like script that allows you to easily navigate Lemmy with your keyboard
License: GNU General Public License v3.0
I suppose the keys can be edited relatively easily in the userscript. But would be really nice if the Chrome Extension had an option to configure the shortcut keys for each action.
Next to being on the Chrome Extension store, it would be very much appreciated if this extension was also released for Firefox via addons.mozilla.org.
Supposedly there's little to none changes that need to be made to make it compatible with Firefox: https://extensionworkshop.com/documentation/develop/porting-a-google-chrome-extension/
After that you should be able to publish the extension for Firefox.
This should be easy
Intended?
I have no clue how to do a Git edit, but basically, this code fixes the issue. A little awkward but since we're looking for a case where the Next button may be either at index 0 or 1, this was all I could come up with off the top of my head.
~ Line 890
case nextPageKey:
case prevPageKey: {
const pageButtons = Array.from(document.querySelectorAll(".paginator>button"));
if (pageButtons && (document.getElementsByClassName('paginator').length > 0)) {
var myNodeList;
if (event.code === nextPageKey) {
myNodeList = document.querySelectorAll(".paginator>.btn.btn-secondary");
for (let i = 0; i < myNodeList.length; i++) {
if(myNodeList[i].textContent === "Next") {
myNodeList[i].click()
}
}
} else {
myNodeList = document.querySelectorAll(".paginator>.btn.btn-secondary");
for (let i = 0; i < myNodeList.length; i++) {
if(myNodeList[i].textContent === "Prev") {
myNodeList[i].click()
}
}
}
}
This script in the current form basically requires having the UI in English because it relies on the button text and assumes it being English.
For starters: In German there's no button labeled "Expand here" to expand images (it's labeled "hier erweitern") or navigating pages fails while searching for "Next" and "Prev" (instead of "Weiter" and "Zurück").
LemmyTools had the same problem: howdy-tsc/LemmyTools#35
And solved it this way: howdy-tsc/LemmyTools#40
Hey, thanks for creating this! Any chance you could add hjkl navigation as used in Vim? I got used to it with RES and I kind of miss it.
Work in progress https://chrome.google.com/webstore/detail/lemmy-keyboard-navigator/lamoeoaekeeklbcekclbceaeafjkdhbi/related
If anyone wants to help let me know, this is the first time I am trying to create a chrome extension
When you use the keyboard shortcuts "L" or "H" on the main page, the cursor resets to the top of the new page, as expected. If you instead click the "Next" or "Prev" button at the bottom of the page, it stays at the same number of articles down you were on the old page.
Would it be possible to provide an option to expand the new highlighted post when using keyboard navigation?
More specifically:
MutationObserver not working on first page load on FF
Navigating to a post and hitting reply does not focus the text editor as expected.
Hitting r
on a comment shows its source instead.
(Using Firefox to browse lemmy.ml)
To duplicate on firefox:
This is annoying because ctrl+L selects the URL bar, which I use to search, so whenever I'm on a lemmy page and use that shortcut, it jumps me to the second post.
(Tested on old.lemmy.world who uses mlmym 0.0.37)
When the selected post has an expanded image, it is not possible to select the next post, and the selected post will keep being selected.
Steps to reproduce:
Actual result: Selected post keeps being selected.
Expected result: Next post should be selected, and the current post should be unselected.
This would be very nice for me. I currently use vimium to hit next which is a little less convenient
Setting the selected item hex code also accepts rgba values. So you can use something with a lot of transparency that will work on both light and dark modes. #49
for example, using rgba(39, 245, 238, 0.18)
:
(Could probably even bring the alpha down to 0.1
with that shade of blue.)
This already works! using v 2.7. The only change needed is the explanatory text.
Can add a user hint that they can use https://rgbacolorpicker.com/ or any of a hundred other tools to find a color they like.
Setting a value with alpha as default across all sites would solve a lot of fiddling around. I do not see it is possible though?
How can I get into the options now?
Out of all of RES, the thing I used most was shift+x to expand everything.
It made just scrolling through the page better.
Is it possible to implement this feature easily?
Hitting i
on any page does not open the inbox on Firefox browsing lemmy.ml.
0.19.x removed 'Prev' button, so on an instance's homepage, 'L' or 'right arrow' does nothing and 'H' or 'left arrow' goes to 'Next'.
Since some instances are still on 0.18.x, I'm not sure if there's an obvious solution to this issue.
Great userscript! I'd love to see a few options added to adjust the behavior of some keystrokes. Both are settings within RES I used to use, and could be optional checkboxes added.
One would be that it automatically scrolls to the next post if you vote. Example: Post 1 is expanded and you press KeyA to upvote, it automatically does the same action as KeyJ and scrolls down to post 2 after upvoting Post 1. This effectively lets you navigate and vote your way down the page with a single keystroke per post.
The second would be an option to toggle if you want to open Comments or Links in a new tab by default, instead of having to hold Shift. I almost never want to open a link in the existing tab, so I have to remember to hit shift each time to get it in a new tab.
Thanks!
Lemmy.world has implemented https://old.lemmy.world
Your keyboard navigation code is great. I appreciate it greatly. Any chance you can get it to work with the modified front end? The code base is here:
Need to improve this line
if (event.key !== 'Meta') {
https://stackoverflow.com/questions/3902635/how-does-one-capture-a-macs-command-key-via-javascript
I'd like to bind expanding the expando to shift+j, and i'd also like to bind collapsing/shrinking the comments to that.
that way I can do almost everything with just j/k and shift+j, but I can't seem to set this up, unfortunately.
Currently the extensions seems to be focused on dark mode, resulting in very weird and impossible to read looks when using a light theme.
You can change the background color in settings, however manually changing that twice a day is bothersome, and that still leaves broken, illegible text.
Examples:
Having recently migrated to lemmy.dbzer0.com, I see the Firefox add-on doesn't work on the lemmy.dbzer0.com domain. Could you please add it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.