V2EX Browser

使用左右箭头切换不同 id 的主题

  1. // ==UserScript==
  2. // @name V2EX Browser
  3. // @namespace https://iamazing.cn/
  4. // @version 0.1
  5. // @description 使用左右箭头切换不同 id 的主题
  6. // @author JustSong
  7. // @match https://www.v2ex.com/t/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. function getTopicId() {
  15. let path = window.location.pathname;
  16. let matched = path.match(/[0-9][0-9]*/);
  17. let id = matched[0];
  18. return parseInt(id);
  19. }
  20.  
  21. function gotoTopic(id) {
  22. if (typeof id === 'number' && id > 0) {
  23. let path = "/t/" + id;
  24. window.location.pathname = path;
  25. }
  26. }
  27.  
  28. window.addEventListener("keydown", function(e) {
  29. let id = getTopicId();
  30. if (e.key === "ArrowLeft") {
  31. id--;
  32. } else if (e.key === "ArrowRight") {
  33. id++;
  34. } else return;
  35. gotoTopic(id);
  36. });
  37. })();

QingJ © 2025

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