Find File Shortcut (GitHub)

Adds a keyboard shortcut to use GitHub's find file feature

目前為 2016-02-28 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Find File Shortcut (GitHub)
  3. // @namespace chriskim06
  4. // @description Adds a keyboard shortcut to use GitHub's find file feature
  5. // @include https://github.com/*/*
  6. // @version 1.3
  7. // @grant none
  8. // @locale en
  9. // ==/UserScript==
  10.  
  11. document.querySelector('html').addEventListener('keydown', function(e) {
  12. if (e.shiftKey && e.which === 80 && e.target.nodeName !== 'INPUT') {
  13. var url = window.location.href.match(/(https:\/\/github\.com\/[A-Za-z0-9_-]+\/[A-Za-z0-9_-]+)(?:\/tree\/)?([A-Za-z0-9_-]+)?/);
  14. if (url !== null) {
  15. var branch = (url[2]) ? url[2] : 'master';
  16. window.location.href = url[1] + '/find/' + branch;
  17. }
  18. }
  19. });
  20.  

QingJ © 2025

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