var followButtonInnerHTML = {
'en' : 'Following',
'tr' : 'Takiptesin'
}
openFollowersWindow().then(function () {
populateUnfollowsPool();
digestUnfollowsPool();
function openFollowersWindow() {
var onFollowersWindowWasOpenedListeners = [];
var openWindowTimeout =
var followersElement =
followersElement.
function digestOnFollowersWindowWasOpenedListeners() {
onFollowersWindowWasOpenedListeners.forEach(function (onFollowersWindowWasOpenedListener) {
onFollowersWindowWasOpenedListener();
});
}
var wasOpened;
setTimeout(function () {
// TODO Verify that the window was indeed opened
wasOpened = true;
digestOnFollowersWindowWasOpenedListeners();
}, openWindowTimeout);
return {
then: function (onFollowersWindowWasOpened) {
if (wasOpened) {
onFollowersWindowWasOpened();
} else {
onFollowersWindowWasOpenedListeners.push(onFollowersWindowWasOpened);
}
}
};
}
function getFollowersElement() {
return getFollowersElementWithUsername(getUsername());
}
function getUsername() {
var pageTitleElement = document.getElementsByTagName('h1')[0];
if (!pageTitleElement) throw new Error('No title to get username from');
return pageTitleElement.innerHTML;
}
function getFollowersElementWithUsername(username)
var followersElement = document.
if (!followersElement) throw new Error('No followers element was found');
return followersElement;
}
var unfollowsPool;
function populateUnfollowsPool()
var buttons = document.
unfollowsPool = [];
for (var i = 0; i < buttons.length; i++) {
var button = buttons[i];
if (button.innerHTML.
var randomTimeoutForUnfollow = Math.floor((Math.random() * 10) + 1) * 1000;
console.log('Following button!');
var unfollow = {
buttonElement: button,
timeout: randomTimeoutForUnfollow
};
unfollowsPool.push(unfollow);
}
function digestUnfollowsPool() {
if (unfollowsPool.length === 0) {
console.log('Unfollow pool empty, repopulating');
populateUnfollowsPool();
var unfollow = unfollowsPool.
var unfollowTimeout =
console.log('Clicking unfollow button in ', unfollowTimeout);
setTimeout(function () {
var unfollowButtonElement = unfollow.buttonElement;
unfollowButtonElement.
console.log('Clicking unfollow button');
unfollowButtonElement.
console.log('Clicked. Continuing digesting unfollow pool');
digestUnfollowsPool();
},
var stopFollowingButton = document.getElementsByClassName('aOOlW -Cab_ ')[0];
setTimeout(function(){
if(stopFollowingButton) {
stopFollowingButton.click();
}
setTimeout(function(){
digestUnfollowsPool();
},unfollowTimeout / 2)
},unfollowTimeout / 2)
}, unfollowTimeout);
}