hub_navigator

Website Navigator With Arrow Key Press

  1. // ==UserScript==
  2. // @name hub_navigator
  3. // @namespace http://your.homepage/
  4. // @version 1.0
  5. // @description Website Navigator With Arrow Key Press
  6. // @match https://*.*/*
  7. // ==/UserScript==
  8. function updatePageNumber(increment) {
  9. const url = window.location.href;
  10.  
  11. // Use regex to find the last numeric sequence in the URL
  12. const regex = /(\d+)(?!.*\d)/;
  13. const match = url.match(regex);
  14.  
  15. if (match) {
  16. // Extract the matched number
  17. let number = parseInt(match[0]);
  18.  
  19. // Adjust the number based on the increment (positive for next, negative for previous)
  20. number += increment;
  21.  
  22. // Replace the old number in the URL with the updated number
  23. const updatedUrl = url.replace(regex, number.toString());
  24.  
  25. // Log the updated URL to the console
  26. console.log('Updated URL:', updatedUrl);
  27.  
  28. // Navigate to the updated URL
  29. window.open(updatedUrl, "_self");
  30. } else {
  31. console.log("No number found in the URL to increment/decrement.");
  32. }
  33. }
  34.  
  35. function checkKeyPressed(e) {
  36. // Right arrow key for increment
  37. if (e.keyCode === 39) {
  38. updatePageNumber(1); // Increment page number
  39. }
  40. // Left arrow key for decrement
  41. if (e.keyCode === 37) {
  42. updatePageNumber(-1); // Decrement page number
  43. }
  44. }
  45.  
  46. // Listen for keydown events
  47. window.addEventListener("keydown", checkKeyPressed, false);
  48.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址