GitHub Pull requests file path

This scripts converts shortened file paths (.../path/to/file) to full path (full/path/to/file)

  1. // ==UserScript==
  2. // @name GitHub Pull requests file path
  3. // @namespace https://doctusoft.com/
  4. // @version 1.1
  5. // @description This scripts converts shortened file paths (.../path/to/file) to full path (full/path/to/file)
  6. // @author Peter Farkas
  7. // @include https://github.com/*
  8. // @require https://code.jquery.com/jquery-2.2.4.min.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. function setCorrectFilePath() {
  13. 'use strict';
  14. var t = $('div.file-info > a');
  15. for(var i = 0; i < t.length; i++) {
  16. t[i].textContent = t[i].title;
  17. }
  18. }
  19.  
  20. function runCorrection() {
  21. var token = window.setInterval(setCorrectFilePath, 1000);
  22. window.setTimeout(function(){
  23. window.clearInterval(token);
  24. }, 20100);
  25. }
  26.  
  27. var regex = /^https:\/\/github.com\/[^\/]+\/[^\/]+\/(?:pull\/[^\/]+\/(?:files|commits\/[^\/]+)?|commit\/[^\/]+)/gi;
  28. console.log(regex.source);
  29.  
  30. var url = "";
  31.  
  32. function pollUrl() {
  33. if(url !== window.location.href) {
  34. url = window.location.href;
  35. if (regex.test(url)) {
  36. runCorrection();
  37. }
  38. }
  39. }
  40.  
  41. window.setInterval(pollUrl, 1000);
  42.  
  43. pollUrl();

QingJ © 2025

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