Github Pull Request From Link

Make pull request original branch linkable

当前为 2014-02-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Github Pull Request From Link
  3. // @namespace https://github.com/jerone/UserScripts/
  4. // @description Make pull request original branch linkable
  5. // @author jerone
  6. // @homepage https://github.com/jerone/UserScripts/tree/master/Github_Pull_Request_From
  7. // @homepageURL https://github.com/jerone/UserScripts/tree/master/Github_Pull_Request_From
  8. // @include *://github.com/*/*/pull/*
  9. // @version 10
  10. // @grant none
  11. // @contribution Changes based on Firefox extension https://github.com/diegocr/GitHubExtIns by https://github.com/diegocr
  12. // ==/UserScript==
  13.  
  14. (function(){
  15. var targetTreeSpan = document.querySelectorAll('span.commit-ref.current-branch.css-truncate.js-selectable-text.expandable')[1],
  16. branchTree = targetTreeSpan.textContent.trim().split(':'),
  17. userTree = branchTree.shift(),
  18. urlTree = [
  19. '//github.com',
  20. userTree,
  21. document.querySelector('.js-current-repository').textContent,
  22. 'tree',
  23. branchTree.join(':')
  24. ].join('/'),
  25. targetTreeA = document.createElement('a');
  26. targetTreeA.setAttribute('href', urlTree);
  27. targetTreeA.innerHTML = targetTreeSpan.innerHTML;
  28. targetTreeSpan.innerHTML = '';
  29. targetTreeSpan.appendChild(targetTreeA);
  30. })();