Expand All Hidden Replies in a 4chan Thread with Keyboard Shortcut

Shows all replies in thread with a keyboard shortcut (press 'a'), excluding typing in textarea

目前為 2024-04-08 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Expand All Hidden Replies in a 4chan Thread with Keyboard Shortcut
  3. // @version 0.2
  4. // @description Shows all replies in thread with a keyboard shortcut (press 'a'), excluding typing in textarea
  5. // @author Anon
  6. // @match https://boards.4chan.org/*
  7. // @grant none
  8. // @license MIT
  9. // @namespace https://greasyfork.org/users/1165708
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Function to show all reply buttons
  16. function showAllReplyButtons() {
  17. // Select all reply buttons
  18. var replyButtons = document.querySelectorAll('.stub .show-reply-button');
  19.  
  20. // Loop through each reply button
  21. replyButtons.forEach(function(button) {
  22. // Click the button
  23. button.click();
  24. });
  25. }
  26.  
  27. // Function to handle keydown event
  28. function handleKeyDown(event) {
  29. // Check if the pressed key is 'a' and the event target is not a textarea
  30. if (event.key === 'a' && event.target.tagName.toLowerCase() !== 'textarea') {
  31. // Show all reply buttons
  32. showAllReplyButtons();
  33.  
  34. // Prevent the default action of the 'a' key
  35. event.preventDefault();
  36. }
  37. }
  38.  
  39. // Add keydown event listener to the document
  40. document.addEventListener('keydown', handleKeyDown);
  41. })();
  42.  
  43.  
  44. (function() {
  45. 'use strict';
  46.  
  47. // Function to show all reply buttons
  48. function showAllReplyButtons() {
  49. // Select all reply buttons
  50. var replyButtons = document.querySelectorAll('.stub .show-reply-button');
  51.  
  52. // Loop through each reply button
  53. replyButtons.forEach(function(button) {
  54. // Click the button
  55. button.click();
  56. });
  57. }
  58.  
  59. // Function to handle keydown event
  60. function handleKeyDown(event) {
  61. // Check if the pressed key is 'a' and the event target is not a textarea
  62. if (event.key === 'a' && event.target.tagName.toLowerCase() !== 'textarea') {
  63. // Show all reply buttons
  64. showAllReplyButtons();
  65.  
  66. // Prevent the default action of the 'a' key
  67. event.preventDefault();
  68. }
  69. }
  70.  
  71. // Add keydown event listener to the document
  72. document.addEventListener('keydown', handleKeyDown);
  73. })();