GITHUB

try to take over the world!

  1. // ==UserScript==
  2. // @name GITHUB
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://github.com/**/stargazers**
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. window.onload = function() {
  16. setTimeout(() => {
  17. var $btnOn = document.querySelectorAll('.js-social-container:not(.on) .btn.btn-sm.js-toggler-target');
  18. var $btnDis = document.querySelectorAll('.js-social-container.on .btn.btn-sm.js-toggler-target');
  19.  
  20. // Blocked by github
  21. if ($btnOn.length <= 2 && $btnDis.length <= 2) {
  22. return setTimeout(() => {
  23. location.reload();
  24. }, 60000)
  25. }
  26.  
  27. var unfollowList = [];
  28. $btnOn.forEach(item => {
  29. if(/Follow/.test(item.getAttribute('title'))) {
  30. unfollowList.push(item);
  31. }
  32. })
  33.  
  34. // Turn the page
  35. if(!unfollowList.length) {
  36. var $pList = document.querySelectorAll(".pagination a");
  37. var pIndex = $pList.length - 1;
  38. return document.querySelectorAll(".pagination a")[pIndex].click();
  39. }
  40.  
  41. var nowIndex = 0;
  42. function clickFollow(unfollowList, nowIndex) {
  43. unfollowList[nowIndex].click();
  44. nowIndex++;
  45. if (nowIndex >= unfollowList.length) {
  46. setTimeout(() => {
  47. location.reload();
  48. }, 100)
  49. } else {
  50. setTimeout(() => {
  51. clickFollow(unfollowList, nowIndex);
  52. }, 300 + parseInt(Math.random()*300));
  53. }
  54. }
  55.  
  56. clickFollow(unfollowList, nowIndex);
  57. }, 100)
  58. }
  59.  
  60. })();