Created
November 15, 2019 14:04
-
-
Save RyanNutt/0776832fc36f0384d7a715fb5bbe5e86 to your computer and use it in GitHub Desktop.
Tapermonkey script to add Travis CI badges to GitHub Classroom
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name GitHub Classroom Badges | |
| // @namespace https://compsci.rocks/ | |
| // @version 0.1 | |
| // @description Add Travis build badges to repos in GitHub Classroom | |
| // @author Ryan Nutt | |
| // @website https://compsci.rocks/ | |
| // @include /^https?://classroom\.github\.com/classrooms/(.*)?/(group-)?assignments/(.*)? | |
| // @grant none | |
| // @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js | |
| // @require https://gist.github.com/raw/2625891/waitForKeyElements.js | |
| // ==/UserScript== | |
| function addBadge(node) { | |
| var token = 'YOUR_TRAVIS_TOKEN'; | |
| var btn = node.find('a.btn[role="button"]'); | |
| if (btn.length) { | |
| var href = btn.attr('href'); | |
| var src = href.replace('github.com', 'api.travis-ci.com') + '.svg?token=' + token + '&branch=master'; | |
| $('<div><a href="' + href.replace('github.com', 'travis-ci.com') + '/builds" target="_blank"><img class="travis-badge" src="' + src + '"></a></div>').insertAfter(btn); | |
| } | |
| } | |
| waitForKeyElements('div.assignment-container .assignment-repo-list-item', addBadge); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment