Github index filter

filter your repo star/fork information

  1. // ==UserScript==
  2. // @name Github index filter
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description filter your repo star/fork information
  6. // @author https://github.com/iMeiji
  7. // @match https://github.com/*
  8. // @grant none
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. // enter your GitHub username
  13. const yourGitHubUserName = "iMeiji";
  14.  
  15. (function () {
  16. 'use strict';
  17. var regex = `^\\/(${yourGitHubUserName})\\/([^\\s]*)`;
  18.  
  19. const observer = new MutationObserver(main);
  20. let article = document.body;
  21.  
  22. let options = {
  23. 'subtree': true,
  24. 'attributes': true
  25. };
  26.  
  27. observer.observe(article, options);
  28.  
  29. function remove(startList, root) {
  30. let removeArr = [];
  31. for (let fork of startList) {
  32. let list = fork.getElementsByClassName("f4 lh-condensed text-bold text-gray-dark");
  33. let a = list.item(0).getElementsByTagName("a");
  34. let h = a.item(0).getAttribute("href");
  35. if (h.search(new RegExp(regex)) !== -1) {
  36. console.log(h);
  37. removeArr.push(fork);
  38. }
  39. }
  40. removeArr.map((value) => {
  41. value.parentNode.removeChild(value);
  42. });
  43. }
  44.  
  45. function main() {
  46. let root = document.getElementsByClassName("news");
  47. let forkList = root.item(0).getElementsByClassName("fork");
  48. let startList = root.item(0).getElementsByClassName("watch_started");
  49. remove(forkList, root);
  50. remove(startList, root);
  51. }
  52. })();