InoReader follow inner links

Script for InoReader that allows to open links that are presented in the article. Press `:` (`;`) to focus a link, or press `'` (`"`) to focus previous ones. Press `[` (`{`) or `]` (`}`) to open selected link in a new tab.

当前为 2024-04-02 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name InoReader follow inner links
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.0.4
  5. // @description Script for InoReader that allows to open links that are presented in the article. Press `:` (`;`) to focus a link, or press `'` (`"`) to focus previous ones. Press `[` (`{`) or `]` (`}`) to open selected link in a new tab.
  6. // @author Kenya-West
  7. // @require https://unpkg.com/hotkeys-js@3.13.7/dist/hotkeys.js
  8. // @match https://*.inoreader.com/feed*
  9. // @match https://*.inoreader.com/article*
  10. // @match https://*.inoreader.com/folder*
  11. // @match https://*.inoreader.com/starred*
  12. // @match https://*.inoreader.com/library*
  13. // @match https://*.inoreader.com/channel*
  14. // @match https://*.inoreader.com/teams*
  15. // @match https://*.inoreader.com/dashboard*
  16. // @match https://*.inoreader.com/pocket*
  17. // @icon https://inoreader.com/favicon.ico?v=8
  18. // @license MIT
  19. // ==/UserScript==
  20.  
  21. (function () {
  22. "use strict";
  23.  
  24. document.head.insertAdjacentHTML("beforeend", `<style>a:focus { outline: 2px solid white; }</style>`);
  25.  
  26. let firstStart = true;
  27. let currentLinkIndex = 0;
  28. let links = []
  29.  
  30. hotkeys('\:,\;', function (event, handler){
  31. event.preventDefault();
  32. if (links.length === 0 && currentLinkIndex === 0) {
  33. currentLinkIndex = -1; // because on first start we need to start from 0
  34. }
  35.  
  36. links = getLinks();
  37. firstStart = false;
  38. if (links.length) {
  39. currentLinkIndex = (currentLinkIndex + 1) % links.length;
  40. links[currentLinkIndex]?.focus();
  41. }
  42. });
  43.  
  44. hotkeys('\',\"', function (event, handler){
  45. // all the same as in previous code block but in reverse order
  46. event.preventDefault();
  47. links = getLinks();
  48. if (links.length) {
  49. currentLinkIndex = (currentLinkIndex - 1 + links.length) % links.length;
  50. links[currentLinkIndex]?.focus();
  51. }
  52. });
  53.  
  54. hotkeys('\],\},\{,\[', function (event, handler){
  55. if (links.length) {
  56. links[currentLinkIndex]?.click();
  57. }
  58. });
  59.  
  60. function getLinks() {
  61. const links = document.querySelectorAll('.article_content a');
  62. return links;
  63. }
  64.  
  65. })();