Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name     Twitter Auto Follow
  3. // @version  2
  4. // @locale en
  5. // @description adds a button to twitter for automatic following of every user displayed
  6. // @include https://twitter.com/*/followers
  7. // @author      Wepwawet
  8. // @run-at document-start
  9. // @grant    none
  10. // @namespace https://greasyfork.org/users/227248
  11. // ==/UserScript==
  12.  
  13. (function() {
  14.     addButton('Autounfollow', selectReadFn, 'button.autounfollow');
  15.  
  16.     var timer_id = 0;
  17.     var secondary_timer_id = 0;
  18.     var followercount = -1;
  19.  
  20.     function secondaryTimer() {
  21.         var curlen = jQuery('.Grid-cell').length;
  22.  
  23.         if (curlen == followercount) {
  24.  
  25.             window.clearInterval(timer_id);
  26.             window.clearInterval(secondary_timer_id);
  27.             document.getElementById('button.autofollow').innerHTML = 'Preparing to unfollow... ' + curlen;
  28.             Secondary();
  29.             return;
  30.         }
  31.  
  32.         followercount = curlen;
  33.     }
  34.  
  35.     function myTimer() {
  36.         window.scrollTo(0, document.body.scrollHeight);
  37.     }
  38.  
  39.     var buttons = 0;
  40.  
  41.     function addButton(text, onclick, buttonName, cssObj) {
  42.         buttons++;
  43.         cssObj = cssObj || {
  44.             display: 'flex',
  45.             'flex-direction': 'column',
  46.             'justify-content': 'space-around',
  47.             'align-items': 'flex-start',
  48.             position: 'fixed',
  49.             bottom: '3%',
  50.             left: '1%',
  51.             'z-index': 3,
  52.             background: '#000000',
  53.             background: '-webkit-linear-gradient(#000000, #000000)',
  54.             background: 'linear-gradient(#000000, #000000)',
  55.             border: '1px solid #556699',
  56.             'border-radius': '5px',
  57.             padding: '8px 20px',
  58.             color: '#ffffff',
  59.             font: 'normal 700 24px/1 "Ubuntu", sans-serif',
  60.             'text-align': 'center',
  61.             'text-shadow': 'none',
  62.         }
  63.         let button = document.createElement('button'),
  64.             btnStyle = button.style
  65.         document.body.appendChild(button)
  66.         button.id = buttonName;
  67.         button.innerHTML = text
  68.         button.onclick = onclick
  69.         Object.keys(cssObj).forEach(key => btnStyle[key] = cssObj[key])
  70.         return button
  71.     }
  72.  
  73.     var running = false;
  74.     var running2 = false;
  75.  
  76.     function selectReadFn() {
  77.         if (running) return;
  78.         running = true;
  79.         timer_id = setInterval(myTimer, 50);
  80.         secondary_timer_id = setInterval(secondaryTimer, 1000);
  81.     }
  82.  
  83.     function Secondary() {
  84.         if (running2) return;
  85.         running2 = true;
  86.         var FOLLOW_PAUSE = 1250;
  87.         var FOLLOW_RAND = 5050;
  88.         var PAGE_WAIT = 2000;
  89.         var __cnt__ = 0;
  90.  
  91.         var eles;
  92.         var __lcnt__ = 0;
  93.         eles = jQuery('.Grid-cell .following .unfollow-text').each(function(i, ele) {
  94.             ele = jQuery(ele);  
  95.             setTimeout(function() {
  96.                 ele.click();
  97.                 if ((eles.length - 1) == i) {
  98.                     return;
  99.                 }
  100.             }, __lcnt__++ * FOLLOW_PAUSE + Math.random() * (FOLLOW_RAND) - FOLLOW_RAND / 2);
  101.             __cnt__++;
  102.  
  103.         });
  104.     }
  105.  
  106.     function isRead(element) {
  107.         childs = element.parentElement.parentElement.parentElement.getElementsByClassName('G3')
  108.         return ![...childs].some(e => e.innerText.search(/unread/i) !== -1)
  109.     }
  110. }());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement