// ==UserScript== // @name Github.desktop.stars.js // @namespace http://zhihaofans.com // @version 0.0.2 // @description 在Github首页显示stars列表 // @author zhihaofans // @match https://github.com/ // @grant none // @require https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js // @note Greasyfork地址:https://greasyfork.org/zh-CN/scripts/25101 // @note Github地址:https://github.com/zhihaofans/Github.desktop.stars.js // @downloadURL https://update.greasyfork.icu/scripts/25101/Githubdesktopstarsjs.user.js // @updateURL https://update.greasyfork.icu/scripts/25101/Githubdesktopstarsjs.meta.js // ==/UserScript== var username=""; function CheckLogin(){ if(jQuery("meta.js-ga-set").attr('content')=="Logged In"){ return true; }else{ return false; } } function initlist(_username){ var items = ''; var itemlimit=10; var hideitem=''; var hideitems=''; var showbutton=''; jQuery.getJSON( "https://api.github.com/users/"+_username+"/starred", function( data ){ var starlen=data.length; jQuery.each( data, function( key, val ) { var ispublic='public'; var relink='/'+val.full_name; var restar=val.stargazers_count; var rename=val.name; var reauther=val.owner.login; if(val.private===true){ ispublic="private"; } var temptext='
  • '+reauther+'/'+rename+' '+restar+'
  • '; if(key>itemlimit){ hideitem+=temptext; }else{ items+=temptext; } }); if(starlen>itemlimit){ hideitems=''; } var listhtml=''; var listdata=jQuery(".dashboard-sidebar.column.one-third").html(); jQuery(".dashboard-sidebar.column.one-third").html(listhtml+listdata); }); } jQuery(document).ready(function() { if(CheckLogin()===true){ username=jQuery("meta[name='user-login']").attr('content'); initlist(username); } });