GitHub - CoderStats

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

2014-03-09 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

  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.0
  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. // @homepageURL https://greatest.deepsurf.us/scripts/179
  15. // @supportURL https://greatest.deepsurf.us/scripts/179/feedback
  16. // @resource CHANGELOG https://raw.github.com/LouCypher/userscripts/master/github/coderstats/CHANGELOG.txt
  17. // @resource LICENSE https://raw.github.com/LouCypher/userscripts/master/licenses/WTFPL/LICENSE.txt
  18. // @include https://github.com/*
  19. // @grant none
  20. // ==/UserScript==
  21. /* This program is free software. It comes without any warranty, to
  22. * the extent permitted by applicable law. You can redistribute it
  23. * and/or modify it under the terms of the Do What The Fuck You Want
  24. * To Public License, Version 2, as published by Sam Hocevar. See
  25. * http://www.wtfpl.net/ for more details. */
  26.  
  27.  
  28.  
  29. function $(aSelector, aNode) {
  30. return (aNode || document).querySelector(aSelector);
  31. }
  32.  
  33. function addReportLink() {
  34. var username = $(".vcard-username");
  35. var details = $(".vcard-details");
  36. if (username && details) {
  37. var list = document.createElement("li");
  38. list.className = "vcard-detail";
  39. list.innerHTML = '<span class="octicon octicon-graph coderstats"></span>'
  40. + '<a href="http://coderstats.net/github/'
  41. + username.textContent + '?ref=userscript">'
  42. + 'CoderStats</a>';
  43. details.appendChild(list);
  44. }
  45. }
  46.  
  47. var siteContainer = $("#site-container");
  48. var vcards = $(".vcard-details");
  49.  
  50. if (siteContainer && vcards) {
  51. addReportLink();
  52.  
  53. if ("MutationObserver" in window || "WebKitMutationObserver" in window) {
  54. new (MutationObserver ? MutationObserver : WebKitMutationObserver)(function(aMutations) {
  55. aMutations.forEach(function(aMutation) {
  56. if (aMutation.removedNodes.length)
  57. if (!$(".vcard-detail .coderstats"))
  58. addReportLink();
  59. });
  60. }).observe(siteContainer, {childList:true});
  61. }
  62. }
  63.  
  64. else
  65. console.log("GitHub - CoderStats user script: Sam Ting Wen Wong!");