📜 ⬆️ ⬇️

Navigation between the best comments

I would like to present you a small solution for optimizing the reading of Habrahabr.

Everyone (especially users of low-power laptops) is familiar with the problem with popular holivarny articles on Habré, which receive hundreds of comments and are terribly slow. In addition to brakes, there is also the problem of extracting useful information. My previous decision, which I had already refused, was based on automatic folding of comments less than a certain number of characters in length.

But after all comments have ratings! Why not use them as a measure of the “informational value” of a comment? After reading the article on hjkl navigation , I had the idea of ​​keyboard navigation on Habré, but not between all the comments, but only those that were rated above a certain threshold. For example, by pressing j, we move to the next comment that received more than 10.
During programming, I remembered another, often referred to here, information, namely the Pareto principle, according to which 20% of comments will carry 80% of the information load. And added the possibility of "smart" navigation, when the movement occurs between 20% of the most highly valued comments.

I implemented it as a UserScript in Greasemonkey. Unfortunately, not everything was possible as planned, the problem is that there is already keyboard navigation on Habrahabr! ( You didn’t know about this? And I didn’t know until I looked at postsHandler.js ). Namely: j - forward, k - backward, h - to the top of the page.
Accordingly, I was able to add my own keystroke handler, but I did not succeed in disabling the activation of the Habrovsk default. If I understood everything correctly, then e.stopPropagation () does not work, because the original handler is higher in the chain of calls to listeners. Therefore, I hung the navigation on the keys n and m (and in the case of the Russian layout, on t and b). If you know how to disable the default handler, please write.
')
For configuration, you will have to edit the source code of the script a little. You can change the value threshold of comments, switch between manual navigation and 20% of the best comments. And the last option is how to jump between comments - in the order of their appearance in the text or to reduce the assessment.

Download Userscript

UPD1: Using SowingSadness, the script now works in Opera and Chrome. I wrapped everything in the closure, now the script will not litter in the global space of the Opera (thanks to bolk for the tip)

Source: https://habr.com/ru/post/78958/


All Articles