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.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         InoReader follow inner links
// @namespace    http://tampermonkey.net/
// @version      0.0.4
// @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.
// @author       Kenya-West
// @require      https://unpkg.com/[email protected]/dist/hotkeys.js
// @match        https://*.inoreader.com/feed*
// @match        https://*.inoreader.com/article*
// @match        https://*.inoreader.com/folder*
// @match        https://*.inoreader.com/starred*
// @match        https://*.inoreader.com/library*
// @match        https://*.inoreader.com/channel*
// @match        https://*.inoreader.com/teams*
// @match        https://*.inoreader.com/dashboard*
// @match        https://*.inoreader.com/pocket*
// @icon         https://inoreader.com/favicon.ico?v=8
// @license      MIT
// ==/UserScript==

(function () {
  "use strict";

  document.head.insertAdjacentHTML("beforeend", `<style>a:focus { outline: 2px solid white; }</style>`);

  let firstStart = true;
  let currentLinkIndex = 0;
  let links = []

  hotkeys('\:,\;', function (event, handler){
    event.preventDefault();
    if (links.length === 0 && currentLinkIndex === 0) {
      currentLinkIndex = -1; // because on first start we need to start from 0
    }

    links = getLinks();
    firstStart = false;
    if (links.length) {
      currentLinkIndex = (currentLinkIndex + 1) % links.length;
      links[currentLinkIndex]?.focus();
    }
  });

  hotkeys('\',\"', function (event, handler){
    // all the same as in previous code block but in reverse order
    event.preventDefault();
    links = getLinks();
    if (links.length) {
      currentLinkIndex = (currentLinkIndex - 1 + links.length) % links.length;
      links[currentLinkIndex]?.focus();
    }
  });

  hotkeys('\],\},\{,\[', function (event, handler){
    if (links.length) {
      links[currentLinkIndex]?.click();
    }
  });

  function getLinks() {
    const links = document.querySelectorAll('.article_content a');
    return links;
  }

})();