Skip to content

Instantly share code, notes, and snippets.

@lexoyo
Last active December 6, 2015 14:27
Show Gist options
  • Save lexoyo/3d70dd4be2a40901caa6 to your computer and use it in GitHub Desktop.
Save lexoyo/3d70dd4be2a40901caa6 to your computer and use it in GitHub Desktop.
Install a "user script" plugin for your browser, and click on "raw" bellow... Then go to twitter and follow the followers of someone. And then after a while unfollow all those you have never retwitted.
// ==UserScript==
// @name twitter-tools
// @namespace lexoyo.user.scripts
// @description Add buttons twitter to gain useful real followers
// @include https://twitter.com/*
// @version 1.1.4
// @run-at document-end
// @grant none
// ==/UserScript==
setTimeout(start, 1500);
var ps = ps || window.history.pushState;
window.history.pushState = function() {
ps.apply(this, arguments);
setTimeout(start, 1500);
};
function start() {
addCss (
'.toubon { \
height: 18px; \
float: right; \
padding: 9px 10px 9px; \
color: #66757F; \
min-width: 65px; \
background-color: #F5F8FA; \
background-image: linear-gradient(#FFF, #F5F8FA); \
background-repeat: no-repeat; \
border: 1px solid #E1E8ED; \
border-radius: 4px; \
cursor: pointer; \
display: inline-block; \
font-size: 14px; \
font-weight: bold; \
line-height: normal; \
position: relative; \
margin: 12px 140px 0 0; \
}'
);
console.log('start');
if(window.location.href.indexOf('/followers') > -1 || window.location.href.indexOf('/search?f=users') > -1) {
addButton('followall', 'Follow all', function (event) {
event.stopPropagation();
followAll();
srollToBottom(followAll, 10000);
});
}
else if(window.location.href.indexOf('twitter.com/following') > -1) {
addButton('unfollowLoosers', 'Unfollow loosers', function (event) {
if(localStorage.getItem('loosers')) {
event.stopPropagation();
unfollowLoosers();
srollToBottom(unfollowLoosers, 10000);
}
else {
alert('Click on "find loosers" button first');
return;
}
});
}
else if(window.location.href.indexOf('/following') > -1) {
addButton('followall', 'Follow all', function (event) {
event.stopPropagation();
followAll();
srollToBottom(followAll, 10000);
});
}
else /* if(window.location.href.indexOf('/with_replies') > -1) */ {
addButton('findLoosers', 'Find loosers', function (event) {
event.stopPropagation();
findLoosers();
srollToBottom(findLoosers, 1000);
});
}
function addButton(id, label, onClick) {
if(document.body.querySelector('#' + id)) return;
var stopScroll = false;
var selector = '.ProfileNav-list';
var buttonHtml = '<div class="toubon" id="' + id + '">' + label + '</div>';
var el = document.body.querySelector(selector);
if(!el) el = document.body.querySelector('.AdaptiveFiltersBar-nav');
el.innerHTML += buttonHtml;
var followall = document.getElementById(id);
followall.addEventListener('click', onClick);
}
function unfollowLoosers() {
var retweeted = {};
if(localStorage.getItem('loosers')) {
retweeted = JSON.parse(localStorage.getItem('loosers'));
}
var unfollowed = [];
var kept = [];
$('.ProfileCard').each(function(){
var login = $('.u-linkComplex-target', this).text()
if(retweeted[login] !== true) {
unfollowed.push(login);
$('.user-actions-follow-button', this).click()
} else {
kept.push(login);
}
});
}
function findLoosers() {
var retweeted = {};
if(localStorage.getItem('loosers')) {
retweeted = JSON.parse(localStorage.getItem('loosers'));
}
$('.username b').each(function() {
if($(this).text() != '') retweeted[$(this).text()] = true;
});
localStorage.setItem('loosers', JSON.stringify(retweeted));
}
function followAll() {
$('.ProfileCard .user-actions.btn-group.not-following').each(function () {
if (!$(this).hasClass('can-dm') &&
!$(this).hasClass('protected') &&
this.innerHTML.indexOf('default_profile_images') === -1) {
$('.user-actions-follow-button', this).click()
}
});
}
var stopScroll = false;
function srollToBottom(cbk, delay) {
var top = $(window).scrollTop();
console.log('srollToBottom start at ', top);
$(window).scrollTop(3000000);
setTimeout(function () {
console.log('timeout', top, $(window).scrollTop() !== top);
cbk();
if (!stopScroll && $(window).scrollTop() !== top) {
srollToBottom(cbk, delay);
}
else alert('The End Of Scroll.', top);
}, delay);
}
function addCss(cssString) {
var head = document.getElementsByTagName('head')[0];
var newCss = document.createElement('style');
newCss.type = "text/css";
newCss.innerHTML = cssString;
head.appendChild(newCss);
}
console.log('end');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment