Next/Previous navigation with arrow keys!

Use the arrow keys to navigate the next or previous pages of tutorials ;)

Verze ze dne 05. 03. 2025. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

  1. // ==UserScript==
  2. // @name Next/Previous navigation with arrow keys!
  3. // @namespace Violentmonkey Scripts
  4. // @match https://www.w3schools.com/*/*
  5. // @grant none
  6. // @version 1.1
  7. // @author AvinashReddy3108 (assisted by ChatGPT)
  8. // @license WTFPL
  9. // @description Use the arrow keys to navigate the next or previous pages of tutorials ;)
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. document.addEventListener('keydown', function(event) {
  16. if (event.target.tagName.toLowerCase() === 'input' || event.target.tagName.toLowerCase() === 'textarea') {
  17. return; // Ignore inputs and textareas
  18. }
  19.  
  20. // Container which has the next/previous buttons
  21. let container = document.querySelector("div.w3-clear.nextprev");
  22. if (!container) return;
  23.  
  24. // The Next/Previous buttons
  25. let prevButton = container.querySelector("a.w3-left.w3-btn");
  26. let nextButton = container.querySelector("a.w3-right.w3-btn");
  27.  
  28. if (event.key === 'ArrowLeft' && prevButton) {
  29. window.location.href = prevButton.href;
  30. } else if (event.key === 'ArrowRight' && nextButton) {
  31. window.location.href = nextButton.href;
  32. }
  33. });
  34. })();