Created
June 4, 2016 21:33
-
-
Save sharnie/32355b05d0f00d702fce05215100f108 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
if ( location.pathname !== "/p/PRODUCT-ID HERE/savers" ) { | |
return false; | |
} | |
function rand_between( num1, num2 ) { | |
return Math.floor(Math.random() * num2) + num1; | |
} | |
function follow_user( username ) { | |
var follow_url = 'https://wanelo.com/' + username + '/follow?last_view=products%23savers' | |
$.post( follow_url ).success(function( response ) { | |
console.log( response ); | |
}); | |
} | |
function get_username( user ) { | |
var $user_follow_btn = $( user ); | |
var username = $user_follow_btn.closest( '.preview-strip-description' ).find( '.preview-strip-description-text > .pull-left > a[title]' ).attr( 'title' ); | |
return username; | |
} | |
var $users_follow_btn = $( '.followable-resource.preview-strip .wb-follow.btn-follow ' ); | |
var users_length = $users_follow_btn.length; | |
var counter = 1; | |
function delayed_follow () { | |
setTimeout(function () { | |
var username = get_username( $users_follow_btn[counter] ); | |
follow_user( username ); | |
counter++; | |
if ( counter < users_length ) { | |
delayed_follow(); | |
} else { | |
window.location.href = $('.page-links .wnl-page.active').next().find( 'a' ).attr( 'href' ); | |
} | |
}, rand_between( 2000, 9000 )); | |
} | |
delayed_follow(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment