Greasy Fork

Shined up real nice.

GitHub - Open Source Report Card

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* This program is free software. It comes without any warranty, to
 * the extent permitted by applicable law. You can redistribute it
 * and/or modify it under the terms of the Do What The Fuck You Want
 * To Public License, Version 2, as published by Sam Hocevar. See
 * http://www.wtfpl.net/ for more details. */

// ==UserScript==
// @name            GitHub - Open Source Report Card
// @namespace       https://userscripts.org/users/12
// @description     Add link to The Open Source Report Card http://osrc.dfm.io/
// @version         2.2
// @author          LouCypher
// @license         WTFPL
// @contributor     Custom Icon Design http://www.iconarchive.com/show/pretty-office-8-icons-by-custom-icon-design.html
// @icon            https://raw.github.com/LouCypher/userscripts/master/github/open-source-report-card/icon48.png
// @icon64URL       https://raw.github.com/LouCypher/userscripts/master/github/open-source-report-card/icon64.png
// @screenshot      https://raw.github.com/LouCypher/userscripts/master/github/open-source-report-card/screenshot.png
// @contributionURL http://loucypher.github.io/userscripts/donate.html?GitHub+Open+Source+Report+Card
// @homepageURL     https://greasyfork.org/scripts/4
// @supportURL      https://greasyfork.org/scripts/4
// @resource        CHANGELOG https://raw.github.com/LouCypher/userscripts/master/github/open-source-report-card/CHANGELOG.txt
// @resource        LICENSE https://raw.github.com/LouCypher/userscripts/master/licenses/WTFPL/LICENSE.txt
// @include         https://github.com/*
// @grant           none
// ==/UserScript==

function $(aSelector, aNode) {
  return (aNode || document).querySelector(aSelector);
}

function addReportLink() {
  var username = $(".vcard-username");
  var details = $(".vcard-details");
  if (username && details) {
    var list = document.createElement("li");
    list.className = "vcard-detail";
    list.innerHTML = '<span class="octicon octicon-graph osrc"></span>'
                   + '<a href="http://osrc.dfm.io/' + username.textContent
                   + '?ref=userscript">Open Source Report Card</a>';
    details.appendChild(list);
  }
}

var siteContainer = $("#site-container");
var vcards = $(".vcard-details");

if (siteContainer && vcards) {
  addReportLink();

  if ("MutationObserver" in window || "WebKitMutationObserver" in window) {
    new (MutationObserver ? MutationObserver : WebKitMutationObserver)(function(aMutations) {
      aMutations.forEach(function(aMutation) {
        if (aMutation.removedNodes.length)
          if (!$(".vcard-detail .osrc"))
            addReportLink();
      });
    }).observe(siteContainer, {childList:true});
  }
}

else
  console.log("GitHub - Open Source Report Card user script: Sam Ting Wen Wong!");