Advertisement
Guest User

Untitled

a guest
Jul 9th, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.17 KB | None | 0 0
  1. if ( window.location.pathname != "/followers" ) {
  2. alert('Oops, you can only run the followers be gone script on your followers page!\n\nClick okay to get redirected to your followers page then run this script again. Thanks, - Jacob.');
  3. window.location = "https://twitter.com/followers";
  4. }
  5.  
  6. var limit = 20,
  7. $removedItems,
  8. i = 0,
  9. num = 0,
  10. r = 0,
  11. count = 0,
  12. rating_array = [],
  13. followers = 0,
  14. numFake = 0,
  15. $soFar,
  16. $item,
  17. $numLeft,
  18. endEarly = false,
  19. following = 0,
  20. userFollowers = $('.profile-card').find("[data-nav='followers'] strong").attr('title'),
  21. userFollowers = parseInt( userFollowers.replace(/,/g, "") ),
  22. upperLimit = userFollowers * .95,
  23. userTweets = $('.profile-card').find("[data-element-term='tweet_stats'] strong").text(),
  24. userTweets = parseInt( userTweets.replace(/,/g, "") ),
  25. userFollowing = $('.profile-card').find("[data-element-term='following_stats'] strong").text(),
  26. userFollowing = parseInt( userFollowing.replace(/,/g, "") ),
  27. rating = 0,
  28. $currItem,
  29. scanLeft = userFollowers,
  30. follower_limit = 10,
  31. dont_delete_limit = 500,
  32. tweet_delete_limit = 0,
  33. newDashboard = '<div class="dashboard new-dashboard" style="position: fixed;"><div class="module enhanced-media-thumbnails "><div class="flex-module media-thumbnails large recent_photos"><div class="directions-block" style="padding: 0 20px;"><h2>Directions for removing twitter followers:</h2><br><p>We need to scan all of your followers to see which are fake and real.</p><hr><br><div id="followers-be-gone-settings" ><h3><i>Settings:</i></h3><br><p>Delete people with less then how many followers:</p><input id="follower_limit" type="number" min="0" max="10000" placeholder="Less than 10 is the default" ><br><br><br><p>Delete people with less then how many tweets:</p><input id="tweet_delete_limit" type="number" min="0" max="10000" placeholder="This is ignored by default"><br><br><br><p>Don\'t delete anyone with more than how many followers (this setting overwrites the last two settings):</p><input id="dont_delete_limit" type="number" min="0" max="10000" placeholder="More than 500 is the default"></div><br><button class="btn" id="start-scan">Click here to get started!</button><br><br><p style="font-size: 12px;">Because you have ' + userFollowers + ' followers, this will take about ' + Math.floor( userFollowers*.0125 ) + ' minutes.</p><br><br><p style="color: #B9B9B9;" >Created by <a href="https://twitter.com/jcbmllgn" target="_blank">@jcbmllgn</a></p> </div></div></div></div>'
  34.  
  35.  
  36. // Thanks for taking a peak at the code, if you have any questions or suggestions, shoot me an email at jacobdmulligan@gmail.com
  37.  
  38.  
  39. function checkRating(item_id) {
  40. return rating_array[item_id][0];
  41. }
  42.  
  43. function setRating(i, newClass) {
  44.  
  45. rating = parseInt(followers)/parseInt(following)*parseInt(tweets);
  46. console.log(rating);
  47.  
  48. // These var's are here for debugging
  49. var $current_follower = $('.profile-modal h1.fullname'),
  50. follower_name = $current_follower.text()
  51.  
  52. if (parseInt(followers) < follower_limit || parseInt(tweets) < tweet_delete_limit ) {
  53. rating = 0;
  54. }
  55.  
  56. if (parseInt(tweets) > 100 || parseInt(followers) > dont_delete_limit) {
  57. rating = 100000;
  58. }
  59.  
  60. $currItem = $( $('#stream-items-id .stream-item')[i] );
  61. $currItem.attr('data-follower-rating', rating)
  62.  
  63. if(rating < limit) {
  64. rating_array.push([rating, numFake, num]);
  65. setRed(num, numFake);
  66. numFake++;
  67. }
  68.  
  69. num++;
  70. scanLeft--;
  71. if (scanLeft <= 1) {
  72. endEarly = true;
  73. $('#follower-tracker').fadeOut();
  74. }
  75. update(numFake, scanLeft);
  76. }
  77.  
  78. function update(numFake, scanLeft) {
  79. $soFar.text(numFake);
  80. $numLeft.text(scanLeft);
  81. }
  82.  
  83. function setRed(num, numFake) {
  84.  
  85. $( $('#stream-items-id .stream-item')[num] )
  86. .css({'background-color' : '#f2dede' , 'border' : '1px solid #eed3d7' , 'position' : 'relative'})
  87. .addClass('setRed' + numFake)
  88. .append('<button class="btn noblock" data-ratingID="' + numFake + '" style="position: absolute; top: 9px; right: 10px;"><span>Don\'t remove me!</span></button>');
  89.  
  90. // If user clicks on the "Don't block" button, this will change the rating
  91.  
  92. $('button.noblock').click(function(){
  93. var changeID = $(this).attr('data-ratingID'),
  94. changeID = parseInt( changeID.replace(/,/g, "") );
  95.  
  96. // Remove item from rating array
  97. rating_array.splice(changeID, 1);
  98.  
  99. $(this)
  100. .removeClass('btn noblock')
  101. .text('Will not be blocked')
  102. .parent().css({'background-color' : 'white' , 'border' : '1px solid #e8e8e8'})
  103. });
  104. }
  105.  
  106. function deleteFollower(limit) {
  107. $('.popover').remove();
  108.  
  109. $.each(rating_array, function() {
  110. rating = this[0];
  111. identifier = this[2];
  112.  
  113. if (rating < limit) {
  114. $currItem = $( $('#stream-items-id .stream-item')[identifier] )
  115.  
  116. // Comment these lines out for testing!
  117. $currItem.find('.dropdown button.user-dropdown').trigger('click')
  118. $currItem.find('.block-text button').trigger('click')
  119. $currItem.find('.follow-button .unblock-text').trigger('click')
  120.  
  121. $currItem.css('background','red');
  122. }
  123. });
  124.  
  125. postDeletion();
  126. };
  127.  
  128. function postDeletion() {
  129. $('.directions-block')
  130. .fadeOut().empty()
  131. .append('<h2><span class="fake-count">' + numFake + '</span> fake followers deleted!</h3><br><p>Those dasterdly fake followers are now gone for good! Thanks for using this script, I\'d be humbuled if you <a href="http://twitter.com/jcbmllgn">follow me on twitter</a> or if you tweeted about this tool:<br><br></p><a href="http://FollowersBeGone.com>FollowersBeGone</a>:<br><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://FollowersBeGone.com" data-text="Remove your fake twitter followers with FollowersBeGone.com!" data-via="jcbmllgn">FollowersBeGone</a><script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script><br><br><a href="#" onclick="location.reload();">Click to reload page</a><br><a target="_blank" href="https://github.com/jcbmllgn/followersBeGone">View source on Github</a><br><a href="mailto:jacobdmulligan@gmail.com">Email me</a><p>-Jacob</p>').fadeIn(); // Inserts directions for next step.
  132. $('.noblock').removeClass('btn').text('No longer follows you');
  133.  
  134.  
  135. // load iframe that trackes stats: number of followers you have, fake followers that I found, fake followers that you actually deleted, how many followers you have, how many times you've tweeted
  136. // Your twitter handle is not being tracked!
  137.  
  138. $('body').append('<iframe style="opacity: 0; width:1px; height:1px; position:absolute; bottom:0px;" src="http://followersBeGone.com/tracker.php?user_followers=' + userFollowers + '&user_tweets=' + userTweets +'&user_following=' + userFollowing + '&num_fake=' + numFake + '&num_deleted=' + numFake +'"></iframe>');
  139. }
  140.  
  141.  
  142. function checkVariable(i, newClass) {
  143.  
  144. var a = $('.profile-modal .profile-card');
  145. if (a) {
  146. tweets = $('#profile_popup').find("[data-nav='profile'] strong").text(),
  147. tweets = parseInt( tweets.replace(/,/g, "") ),
  148. following = $('#profile_popup').find("[data-nav='following'] strong").text(),
  149. following = parseInt( following.replace(/,/g, "") ),
  150. followers = $('#profile_popup').find("[data-nav='followers'] strong").text(),
  151. followers = parseInt( followers.replace(/,/g, "") );
  152.  
  153. if( newClass && following > 1 || followers > 1 ){
  154. setRating(i);
  155. } else {
  156. setTimeout("checkVariable(i, newClass)" , 100); // call myself again in 50 msecs
  157. }
  158. }
  159. else {
  160. setTimeout("checkVariable(i, newClass)" , 100); // call myself again in 50 msecs
  161. }
  162. };
  163.  
  164.  
  165. function followerScan (num_scan) {
  166.  
  167. $('#end-scan').click(function(){
  168. console.log('ending scan early');
  169. $('#follower-tracker').fadeOut();
  170. endEarly = true;
  171. });
  172.  
  173. setTimeout(function () {
  174.  
  175. newClass = 'count' + i;
  176. $currItem = $( $('#stream-items-id .stream-item')[i] );
  177. var item_length = $('#stream-items-id .stream-item').length;
  178.  
  179. $currItem.find('strong.fullname').trigger('click')
  180. $currItem.addClass(newClass);
  181.  
  182. setTimeout("checkVariable(i, newClass)" , 100);
  183.  
  184. if( i >= item_length-15 ){
  185. $('#stream-items-id .stream-item').find('.user-actions').css('opacity' , '0');
  186. $("html, body").animate({ scrollTop: $(document).height() }, "fast");
  187. }
  188.  
  189. if ( upperLimit === i || endEarly === true) {
  190. deleteStep();
  191. return
  192.  
  193. } else {
  194. followerScan();
  195.  
  196. }
  197.  
  198. i++;
  199. }, 275)
  200. }
  201.  
  202. function deleteStep() {
  203. $("html, body").animate({ scrollTop: 0 }, "slow", function(){
  204. $('.close-modal-background-target').trigger('click');
  205. $('.directions-block')
  206. .fadeOut().empty()
  207. .append('<h2>You have <span class="fake-count">' + numFake + '</span> fake followers!</h2><br><p>Scroll down the list on the right and you\'ll see that all fake followers are highlighted in red. If any of these followers where wrongly marked as fake, just click on the "Don\'t block me" button then move on.</p><br><p>Now that we\'ve selected the fake followers, click this button to remove them, note that this CANNOT be undone!</p><br><br><button class="btn primary-btn" id="delete-followers">Delete fake followers</button><br><br><p style="font-style: italic;">Depending on the number of followers you have, this may take up to a couple minutes to process!</p>').fadeIn(); // Inserts directions for next step.
  208.  
  209. $('#delete-followers').click(function(){
  210. deleteFollower(limit);
  211. });
  212. });
  213. }
  214.  
  215. function makeDashboard() {
  216. // remove old dashboard:
  217. $removedItems = $('.dashboard').addClass('removed-dashboard');
  218. $removedItems.fadeOut();
  219.  
  220. // Insert new dashboard:
  221. $('.dashboard').after(newDashboard);
  222. }
  223.  
  224. function undoDashboard() {
  225. $removedItems.fadeId();
  226. }
  227.  
  228. makeDashboard();
  229.  
  230. $('#start-scan').click(function(){
  231. $('body').append('<div style="position: fixed;top: 60px;right: 50px;z-index:999999;font-weight: bold;color: white;background: #3e3e3e;padding: 20px;font-size: 20px;" id="follower-tracker"><p><span class="soFar">0</span> fake followers so far.</p><br><br><p>Followers left to scan: <span class="numLeft">' + userFollowers + '</span></p><br><br><button class="btn" id="end-scan">Click here to end scan early</button><br><br><p style="font-size:14px;font-weight:normal;">If the scan starts slowing down, you can<br>end it early, delete current fake followers,<br>then rescan..</p></div>');
  232. $soFar = $('#follower-tracker span.soFar');
  233. $numLeft = $('#follower-tracker span.numLeft');
  234. followerScan(50);
  235.  
  236. $('#followers-be-gone-settings').remove();
  237. });
  238.  
  239. $('#follower_limit').keyup(function(e) {
  240. var $this = $(this);
  241. follower_limit = parseInt( $this.val() );
  242. console.log(follower_limit);
  243. });
  244.  
  245. $('#dont_delete_limit').keyup(function(e) {
  246. var $this = $(this);
  247. dont_delete_limit = parseInt( $this.val() );
  248. console.log(dont_delete_limit);
  249. });
  250.  
  251. $('#tweet_delete_limit').keyup(function(e) {
  252. var $this = $(this);
  253. tweet_delete_limit = parseInt( $this.val() );
  254. console.log(tweet_delete_limit);
  255. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement