GitHub - Open Source Report Card

Add link to The Open Source Report Card http://osrc.dfm.io/

Verze ze dne 19. 02. 2014. Zobrazit nejnovější verzi.

  1. // ==UserScript==
  2. // @name GitHub - Open Source Report Card
  3. // @namespace https://userscripts.org/users/12
  4. // @description Add link to The Open Source Report Card http://osrc.dfm.io/
  5. // @version 1.20140219123728
  6. // @author LouCypher
  7. // @license WTFPL
  8. // @icon https://raw.github.com/LouCypher/userscripts/master/github/open-source-report-card/icon48.png
  9. // @icon64URL https://raw.github.com/LouCypher/userscripts/master/github/open-source-report-card/icon64.png
  10. // @screenshot https://raw.github.com/LouCypher/userscripts/master/github/open-source-report-card/screenshot.jpg
  11. // @contributionURL http://loucypher.github.io/userscripts/donate.html?GitHub+Open+Source+Report+Card
  12. // @homepageURL https://userscripts.org/scripts/show/297042
  13. // @supportURL https://userscripts.org/scripts/discuss/297042
  14. // @resource CHANGELOG https://raw.github.com/LouCypher/userscripts/master/github/open-source-report-card/CHANGELOG.txt
  15. // @resource LICENSE https://raw.github.com/LouCypher/userscripts/master/licenses/WTFPL/LICENSE.txt
  16. // @include https://github.com/*
  17. // @grant none
  18. // ==/UserScript==
  19. /* This program is free software. It comes without any warranty, to
  20. * the extent permitted by applicable law. You can redistribute it
  21. * and/or modify it under the terms of the Do What The Fuck You Want
  22. * To Public License, Version 2, as published by Sam Hocevar. See
  23. * http://www.wtfpl.net/ for more details. */
  24.  
  25.  
  26.  
  27. function $(aSelector, aNode) {
  28. return (aNode || document).querySelector(aSelector);
  29. }
  30.  
  31. function addReportLink() {
  32. var username = $(".vcard-username");
  33. var details = $(".vcard-details");
  34. if (username && details) {
  35. var list = document.createElement("li");
  36. list.className = "vcard-detail";
  37. list.innerHTML = '<span class="octicon octicon-graph"></span>'
  38. + '<a href="http://osrc.dfm.io/' + username.textContent
  39. + '?ref=userscript">Open Source Report Card</a>';
  40. details.appendChild(list);
  41. }
  42. }
  43.  
  44. var siteContainer = $("#site-container");
  45. var vcard = $(".column-sec.vcard");
  46. if (siteContainer && vcard) {
  47. addReportLink();
  48.  
  49. if ("MutationObserver" in window || "WebKitMutationObserver" in window) {
  50. new (MutationObserver ? MutationObserver : WebKitMutationObserver)(function(aMutations) {
  51. aMutations.forEach(function(aMutation) {
  52. if (aMutation.removedNodes.length)
  53. if (!$(".vcard-detail .octicon-graph"))
  54. addReportLink();
  55. });
  56. }).observe(siteContainer, {childList:true});
  57. }
  58. }