Github Pull Request From Link

Make pull request original branch linkable

当前为 2014-03-17 提交的版本,查看 最新版本

  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. (function(){
  14. var targetTreeSpan = document.querySelectorAll('span.commit-ref.current-branch.css-truncate.js-selectable-text.expandable')[1],
  15. branchTree = targetTreeSpan.textContent.trim().split(':'),
  16. userTree = branchTree.shift(),
  17. urlTree = [
  18. '//github.com',
  19. userTree,
  20. document.querySelector('.js-current-repository').textContent,
  21. 'tree',
  22. branchTree.join(':')
  23. ].join('/'),
  24. targetTreeA = document.createElement('a');
  25. targetTreeA.setAttribute('href', urlTree);
  26. targetTreeA.innerHTML = targetTreeSpan.innerHTML;
  27. targetTreeSpan.innerHTML = '';
  28. targetTreeSpan.appendChild(targetTreeA);
  29. })();