GitHub unknown license

A userscript that adds "unknown license" message in repos with no license set

目前为 2020-03-29 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name GitHub unknown license
  3. // @version 0.1.0
  4. // @description A userscript that adds "unknown license" message in repos with no license set
  5. // @license MIT
  6. // @author Rob Garrison
  7. // @namespace https://github.com/Mottie
  8. // @include https://github.com/*
  9. // @run-at document-idle
  10. // @grant none
  11. // @require https://greasyfork.org/scripts/28721-mutations/code/mutations.js?version=666427
  12. // @require https://greasyfork.org/scripts/398877-utils-js/code/utilsjs.js?version=785415
  13. // @icon https://github.githubassets.com/pinned-octocat.svg
  14. // ==/UserScript==
  15. (() => {
  16. "use strict";
  17. /* global $ */
  18.  
  19. // Example page with no license
  20. // https://github.com/isaacs/github
  21. const lawIcon = `
  22. <svg
  23. class="octicon octicon-law"
  24. viewBox="0 0 14 16"
  25. width="14"
  26. height="16"
  27. aria-hidden="true"
  28. >
  29. <path
  30. fill-rule="evenodd"
  31. fill="currentColor"
  32. class="text-yellow"
  33. d="M7 4c-.83 0-1.5-.67-1.5-1.5S6.17 1 7 1s1.5.67 1.5 1.5S7.83 4 7 4zm7
  34. 6c0 1.11-.89 2-2 2h-1c-1.11 0-2-.89-2-2l2-4h-1c-.55
  35. 0-1-.45-1-1H8v8c.42 0 1 .45 1 1h1c.42 0 1 .45 1 1H3c0-.55.58-1
  36. 1-1h1c0-.55.58-1 1-1h.03L6 5H5c0 .55-.45 1-1 1H3l2 4c0 1.11-.89 2-2
  37. 2H2c-1.11 0-2-.89-2-2l2-4H1V5h3c0-.55.45-1 1-1h4c.55 0 1 .45 1
  38. 1h3v1h-1l2 4zM2.5 7L1 10h3L2.5 7zM13 10l-1.5-3-1.5 3h3z"
  39. />
  40. </svg>`;
  41.  
  42. const entry = document.createElement("li");
  43. entry.innerHTML = `
  44. <a href="https://choosealicense.com/" class="text-yellow">
  45. ${lawIcon} unknown license
  46. </a>`;
  47.  
  48. function init() {
  49. const summary = $(".numbers-summary");
  50. if (!$(".octicon-law", summary)) {
  51. summary.append(entry.cloneNode(true));
  52. }
  53. }
  54.  
  55. on(document, "ghmo:container", init);
  56. init();
  57.  
  58. })();