Greasy Fork 支持简体中文。

GitHub Latest

Always keep an eye on the latest activity of your favorite projects

目前為 2019-12-10 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name GitHub Latest
  3. // @namespace https://github.com/Ede123/userscripts
  4. // @version 1.0.6
  5. // @description Always keep an eye on the latest activity of your favorite projects
  6. // @icon https://raw.githubusercontent.com/Ede123/userscripts/master/icons/GitHub.png
  7. // @author Eduard Braun <eduard.braun2@gmx.de>
  8. // @license GPL-3.0+; http://www.gnu.org/copyleft/gpl.html
  9. // @include https://github.com/*
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13.  
  14. // redirect link to automatically sort "your stars" by "recently active"
  15. document.body.addEventListener('mousedown', function(e){
  16. var targ = e.target || e.srcElement;
  17. if ( targ && targ.href && targ.href.match(/tab=stars$/) ) {
  18. targ.href = targ.href.replace(/tab=stars$/, "tab=stars&sort=updated");
  19. }
  20. });
  21.  
  22. // add a button to "latest issues"
  23. function addLatestButton() {
  24. // do not add button again if already present
  25. if (document.getElementById("latest-button")) {
  26. return;
  27. }
  28.  
  29. var reponav = document.getElementsByClassName("reponav");
  30. if (reponav && (reponav = reponav[0])) {
  31. var button = reponav.children[1].firstElementChild.cloneNode(true);
  32. button.id = "latest-button"
  33. button.href += "?sort=updated";
  34. button.style.float = "right";
  35.  
  36. // unselect
  37. button.classList.remove("selected");
  38. button.removeAttribute("data-selected-links");
  39.  
  40. // adjust icon
  41. button.firstElementChild.firstElementChild.setAttribute("class","octicon octicon-flame");
  42. button.firstElementChild.firstElementChild.firstChild.setAttribute("d","M5.05 0.31c0.81 2.17 0.41 3.38-0.52 4.31-0.98 1.05-2.55 1.83-3.63 3.36-1.45 2.05-1.7 6.53 3.53 7.7-2.2-1.16-2.67-4.52-0.3-6.61-0.61 2.03 0.53 3.33 1.94 2.86 1.39-0.47 2.3 0.53 2.27 1.67-0.02 0.78-0.31 1.44-1.13 1.81 3.42-0.59 4.78-3.42 4.78-5.56 0-2.84-2.53-3.22-1.25-5.61-1.52 0.13-2.03 1.13-1.89 2.75 0.09 1.08-1.02 1.8-1.86 1.33-0.67-0.41-0.66-1.19-0.06-1.78 1.25-1.23 1.75-4.09-1.88-6.22l-0.02-0.02z");
  43.  
  44. // remove counter
  45. var counter = button.getElementsByClassName('counter')[0] || button.getElementsByClassName('Counter')[0];
  46. if (counter) {
  47. button.removeChild(counter);
  48. }
  49.  
  50. var items = button.querySelectorAll('[itemprop]');
  51. for (var i = 0; i < items.length; i++) {
  52. // adjust name
  53. if (items[i].getAttribute("itemprop") == "name") {
  54. items[i].textContent = "Latest issues"
  55. }
  56. }
  57.  
  58. reponav.appendChild(button);
  59. }
  60. }
  61.  
  62. addLatestButton();
  63.  
  64. // GitHub uses pjax to navigate between documents
  65. document.addEventListener('pjax:success', addLatestButton);