GitHub - CoderStats

Add link to CoderStats http://http://coderstats.net//

Versione datata 09/03/2014. Vedi la nuova versione l'ultima versione.

  1. // ==UserScript==
  2. // @name GitHub - CoderStats
  3. // @id github-coderstats@loucypher
  4. // @namespace https://github.com/LouCypher/userscripts
  5. // @description Add link to CoderStats http://http://coderstats.net//
  6. // @version 1.0pre
  7. // @author LouCypher
  8. // @license WTFPL
  9. // @contributor Custom Icon Design http://www.iconarchive.com/show/pretty-office-8-icons-by-custom-icon-design.html
  10. // @icon https://raw.github.com/LouCypher/userscripts/master/github/open-source-report-card/icon48.png
  11. // @icon64URL https://raw.github.com/LouCypher/userscripts/master/github/open-source-report-card/icon64.png
  12. // @screenshot https://raw.github.com/LouCypher/userscripts/master/github/coderstats/screenshot.png
  13. // @contributionURL http://loucypher.github.io/userscripts/donate.html?GitHub+-+CoderStats
  14. // @resource CHANGELOG https://raw.github.com/LouCypher/userscripts/master/github/coderstats/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 coderstats"></span>'
  38. + '<a href="http://coderstats.net/github/'
  39. + username.textContent + '?ref=userscript">'
  40. + 'CoderStats</a>';
  41. details.appendChild(list);
  42. }
  43. }
  44.  
  45. var siteContainer = $("#site-container");
  46. var vcards = $(".vcard-details");
  47.  
  48. if (siteContainer && vcards) {
  49. addReportLink();
  50.  
  51. if ("MutationObserver" in window || "WebKitMutationObserver" in window) {
  52. new (MutationObserver ? MutationObserver : WebKitMutationObserver)(function(aMutations) {
  53. aMutations.forEach(function(aMutation) {
  54. if (aMutation.removedNodes.length)
  55. if (!$(".vcard-detail .coderstats"))
  56. addReportLink();
  57. });
  58. }).observe(siteContainer, {childList:true});
  59. }
  60. }
  61.  
  62. else
  63. console.log("GitHub - CoderStats user script: Sam Ting Wen Wong!");