Greasy Fork is available in English.

Chapter Navigation using arrows in bcatranslation website

Navigate to the next chapter when pressing the right arrow key

  1. // ==UserScript==
  2. // @name Chapter Navigation using arrows in bcatranslation website
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Navigate to the next chapter when pressing the right arrow key
  6. // @author kleindev
  7. // @match *://bcatranslation.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=bcatranslation.com
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to handle the right arrow key press
  16. function handleKeyDown(event) {
  17. if (event.key === 'ArrowRight') {
  18. // Find the <p> tag containing the link with text "[Next chapter]"
  19. const paragraph = Array.from(document.querySelectorAll('p')).find(p =>
  20. p.querySelector('a') && p.querySelector('a').textContent.trim() === '[Next Chapter]'
  21. );
  22.  
  23. if (paragraph) {
  24. // Get the <a> element within the found <p> tag
  25. const link = paragraph.querySelector('a');
  26. if (link) {
  27. // Navigate to the href of the <a> tag
  28. window.location.href = link.href;
  29. }
  30. }
  31. }
  32. if (event.key === 'ArrowLeft') {
  33. // Find the <p> tag containing the link with text "[Next chapter]"
  34. const paragraph = Array.from(document.querySelectorAll('p')).find(p =>
  35. p.querySelector('a') && p.querySelector('a').textContent.trim() === '[Previous Chapter]'
  36. );
  37.  
  38. if (paragraph) {
  39. // Get the <a> element within the found <p> tag
  40. const link = paragraph.querySelector('a');
  41. if (link) {
  42. // Navigate to the href of the <a> tag
  43. window.location.href = link.href;
  44. }
  45. }
  46. }
  47. }
  48.  
  49. // Attach the event listener to the document
  50. document.addEventListener('keydown', handleKeyDown);
  51. })();