Use shortcut to open your github

Use shortcut open your github

  1. // ==UserScript==
  2. // @name Use shortcut to open your github
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.3
  5. // @description Use shortcut open your github
  6. // @author You
  7. // @include https://github.com/
  8. // @match https://github.com/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. let commaCount = 0; // We can move the counter outside of the event listener
  18. let timer = null
  19. document.addEventListener('keydown', function(event) {
  20. const href = `https://github1s.com${location.pathname}`;
  21. if (timer) clearTimeout(timer)
  22. // We can check if the key pressed is the comma key (key code 188)
  23. if (event.code === 'Semicolon' && event.key === ';') {
  24. // We can increment the counter each time the comma key is pressed
  25. commaCount++;
  26. // If the comma key has been pressed twice, we can open a link
  27. if (commaCount === 2) {
  28. window.open(href);
  29. // We can reset the counter after the link is opened
  30. commaCount = 0;
  31. }
  32. } else {
  33. // We can reset the counter if any other key is pressed
  34. commaCount = 0;
  35. }
  36.  
  37. timer = setTimeout(() => { commaCount = 0 }, 1e3)
  38. });
  39. })();

QingJ © 2025

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