python文档方向键翻页

方便读python文档

  1. // ==UserScript==
  2. // @name python文档方向键翻页
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 方便读python文档
  6. // @author You
  7. // @match https://docs.python.org/zh-cn/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. let key_text = {37:"上一页",39:"下一页"};
  13. document.onkeydown=function(e){
  14. let k = window.event?e.keyCode:e.which;
  15. for (let key in key_text) {
  16. if(k==key){
  17. let ass = document.querySelectorAll("div.related>ul>li.right>a");
  18. for(let a of ass){
  19. if(a.innerHTML== key_text[key]){
  20. a.click();
  21. }
  22. }
  23. }
  24. }
  25. }
  26. })();