GitHub - CoderStats

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

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址