GitHub My Issues

Add a link to issues you've contributed to on GitHub

当前为 2020-09-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GitHub My Issues
  3. // @description Add a link to issues you've contributed to on GitHub
  4. // @author chocolateboy
  5. // @copyright chocolateboy
  6. // @version 0.0.1
  7. // @namespace https://github.com/chocolateboy/userscripts
  8. // @license GPL: http://www.gnu.org/copyleft/gpl.html
  9. // @include https://github.com/
  10. // @include https://github.com/*
  11. // @require https://code.jquery.com/jquery-3.5.1.slim.min.js
  12. // @grant GM_log
  13. // @inject-into auto
  14. // ==/UserScript==
  15.  
  16. // XXX note: the unused grant is a workaround for a Greasemonkey bug:
  17. // https://github.com/greasemonkey/greasemonkey/issues/1614
  18.  
  19. const user = $('meta[name="user-login"]').attr('content')
  20. const $issues = $('[aria-label="Global"] a[href="/issues"]')
  21.  
  22. if (user && $issues.length) {
  23. const repo = $('meta[name="octolytics-dimension-repository_nwo"]').attr('content')
  24. const query = escape(`involves:${user}`)
  25. const href = repo ? `/${repo}/issues?q=${query}` : `/issues?q=${query}`
  26. const $link = $issues.clone()
  27. .attr({ href, 'data-hotkey': 'g I' })
  28. .text('My Issues')
  29.  
  30. $issues.after($link)
  31. }