// ==UserScript== // @name GitHub Show Repo Issues // @namespace github-show-repo-issues // @description Show repo issues count on the repository tab & organization page (https://github.com/:user) // @version 2.0.1 // @include https://github.com/* // @grant GM_addStyle // @grant GM_xmlhttpRequest // @run-at document-end // @require https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js // @author Rob Garrison >> http://github.com/Mottie // @downloadURL none // ==/UserScript== ( function( $ ) { 'use strict'; // look for repo tab if ( $( '.tabnav-tab.selected' ).length || $( '.repo-list' ).length ) { // Does not include forks & only includes the first 10 repos, or first 20 on the // organization page - these are the repos showing the participation graphs var max = $( '.tabnav-tab.selected' ).length ? 10 : 20, $items = $('.repo-list-item') .filter(':lt(' + max + ')') .filter('.public:not(.fork)') .find('a.repo-list-stat-item[aria-label="Forks"]'), // bug icon img = 'data:image/svg+xml;charset=utf8,', // api v3: https://api.github.com/repos/:user/:repo/issues?state=open api = 'https://api.github.com/repos', // the API only reports the apiMax = 30; // add bug image background GM_addStyle( '.repo-list-stats a.issues { padding-left: 18px; background: url("'+ img + '") no-repeat 0 2px !important; }' ); $items.each( function( index ) { var $this = $( this ), // // 1 // repo = $this.attr( 'href' ).replace( /network/g,'' ); GM_xmlhttpRequest({ method : 'GET', url : api + repo + 'issues?state=open', onload : function( response ) { var issues, data = $.parseJSON( response.responseText || 'null' ); if ( data ) { issues = data.length; if ( issues >= apiMax ) { issues += '+'; } $this.after( '' + issues + '' ); } } }); }); } })( jQuery.noConflict( true ) );