@@ -1,153 +1,166 @@
( Linkedin = {
data : { } ,
config : {
inspectorSpeed : 2000 ,
sendSpeed : 3000 ,
pagerSpeed : 10000 ,
scrollDownAuto : 500 ,
debug : true ,
message : 'Your custom note message (max 300 length)'
} ,
setEvents : function ( ) {
this . debug ( 'set events' ) ;
} ,
debug : function ( a ) {
if ( this . config . debug && typeof console === 'object' ) {
console . log ( a )
}
} ,
init : function ( ) {
this . debug ( 'start script' ) ;
this . setDefaults ( ) ;
this . setEvents ( ) ;
this . inspect ( ) ;
} ,
complete : function ( ) {
this . debug ( 'script complete' ) ;
} ,
sleep : function ( a ) {
this . setScroll ( ) ;
var start = new Date ( ) . getTime ( ) ;
for ( var i = 0 ; i < 1e7 ; i ++ ) {
if ( ( new Date ( ) . getTime ( ) - start ) > a ) {
break ;
}
data : { } ,
config : {
inspectorSpeed : 5000 ,
sendSpeed : 4000 ,
pagerSpeed : 10000 ,
scrollDownAuto : 600 ,
debug : true ,
message : 'Your custom note message (max 300 length)'
} ,
setEvents : function ( ) {
this . debug ( 'set events' ) ;
} ,
debug : function ( a ) {
if ( this . config . debug && typeof console === 'object' ) {
console . log ( a )
}
} ,
init : function ( ) {
this . debug ( 'start script' ) ;
this . setDefaults ( ) ;
this . setEvents ( ) ;
this . inspect ( ) ;
} ,
complete : function ( ) {
this . debug ( 'script complete' ) ;
} ,
sleep : function ( a ) {
this . setScroll ( ) ;
var start = new Date ( ) . getTime ( ) ;
for ( var i = 0 ; i < 1e7 ; i ++ ) {
if ( ( new Date ( ) . getTime ( ) - start ) > a ) {
break ;
}
} ,
totalRows : function ( ) {
return $ ( '.search-result' ) . length ;
} ,
compile : function ( ) {
this . data . pageButtons = $ ( "button.search-result__action-button" ) . filter ( function ( ) {
return $ . trim ( $ ( this ) . text ( ) ) === "Connect" ;
} ) ;
this . data . pageButtonTotal = this . data . pageButtons . length ;
} ,
stop : function ( ) {
clearInterval ( Linkedin . data . pageInterval ) ;
clearInterval ( Linkedin . data . nextInterval ) ;
} ,
setDefaults : function ( ) {
clearInterval ( Linkedin . data . pageInterval ) ;
clearInterval ( Linkedin . data . nextInterval ) ;
this . data = {
pageInterval : null ,
nextInterval : null ,
pageButtons : { } ,
pageButtonIndex : 0 ,
pageButtonTotal : 0
} ;
} ,
sendInvites : function ( ) {
}
} ,
totalRows : function ( ) {
return $ ( '.search-result' ) . length ;
} ,
compile : function ( ) {
this . data . pageButtons = $ ( "button.search-result__action-button" ) . filter ( function ( ) {
return $ . trim ( $ ( this ) . text ( ) ) === "Connect" ;
} ) ;
this . data . pageButtonTotal = this . data . pageButtons . length ;
} ,
stop : function ( ) {
clearInterval ( Linkedin . data . pageInterval ) ;
clearInterval ( Linkedin . data . nextInterval ) ;
} ,
setDefaults : function ( ) {
clearInterval ( Linkedin . data . pageInterval ) ;
clearInterval ( Linkedin . data . nextInterval ) ;
this . data = {
pageInterval : null ,
nextInterval : null ,
pageButtons : { } ,
pageButtonIndex : 0 ,
pageButtonTotal : 0
} ;
} ,
sendInvites : function ( ) {
this . compile ( ) ;
this . setScroll ( ) ;
this . debug ( 'validing' ) ;
this . compile ( ) ;
this . setScroll ( ) ;
this . debug ( 'validing' ) ;
if ( this . data . pageButtonTotal === 0 ) {
if ( this . data . pageButtonTotal === 0 ) {
this . sleep ( this . config . sendSpeed ) ;
this . sleep ( this . config . sendSpeed ) ;
return this . nextPage ( ) ;
}
return this . nextPage ( ) ;
}
this . sleep ( this . data . speed ) ;
this . sleep ( this . data . speed ) ;
this . debug ( 'sending invite ' + ( this . data . pageButtonIndex + 1 ) + '/' + this . data . pageButtonTotal ) ;
this . debug ( 'sending invite ' + ( this . data . pageButtonIndex + 1 ) + '/' + this . data . pageButtonTotal ) ;
var button = this . data . pageButtons [ this . data . pageButtonIndex ] ;
var button = this . data . pageButtons [ this . data . pageButtonIndex ] ;
this . debug ( 'clicking connect' ) ;
$ ( button ) . click ( ) ;
this . sleep ( Linkedin . config . sendSpeed ) ;
this . debug ( 'clicking connect' ) ;
$ ( button ) . click ( ) ;
this . sleep ( Linkedin . config . sendSpeed ) ;
this . debug ( 'adding a note' ) ;
$ ( "button:contains('Add a note')" ) . click ( ) ;
this . sleep ( Linkedin . config . sendSpeed ) ;
this . debug ( 'adding a note' ) ;
$ ( "button:contains('Add a note')" ) . click ( ) ;
this . sleep ( Linkedin . config . sendSpeed ) ;
this . debug ( 'write a note' ) ;
var textArea = $ ( 'textarea[id="custom-message"]' ) ;
textArea . val ( this . config . message ) ;
this . sleep ( Linkedin . config . sendSpeed ) ;
this . debug ( 'write a note' ) ;
var textArea = $ ( 'textarea[id="custom-message"]' ) ;
textArea . val ( this . config . message ) ;
this . sleep ( Linkedin . config . sendSpeed ) ;
this . debug ( 'send click' ) ;
$ ( "button:contains('Send invitation')" ) . click ( ) ;
this . sleep ( Linkedin . config . sendSpeed ) ;
this . debug ( 'send click' ) ;
$ ( "button:contains('Send invitation')" ) . click ( ) ;
this . sleep ( Linkedin . config . sendSpeed ) ;
this . debug ( 'close window' ) ;
$ ( "button:contains('Cancel')" ) . click ( ) ;
this . sleep ( Linkedin . config . sendSpeed ) ;
this . debug ( 'close window' ) ;
$ ( "button:contains('Cancel')" ) . click ( ) ;
this . sleep ( Linkedin . config . sendSpeed ) ;
if ( this . data . pageButtonIndex >= ( this . data . pageButtonTotal - 1 ) ) {
return this . nextPage ( ) ;
} else {
this . data . pageButtonIndex ++ ;
return this . sendInvites ( ) ;
this . debug ( 'ignore confirm mail' ) ;
if ( $ ( '[id=email]' ) . length ) {
$ ( '.send-invite__cancel-btn' ) . click ( ) ;
}
this . sleep ( Linkedin . config . sendSpeed ) ;
if ( this . data . pageButtonIndex >= ( this . data . pageButtonTotal - 1 ) && this . closeAll ( ) ) {
return this . nextPage ( ) ;
} else {
this . data . pageButtonIndex ++ ;
return this . sendInvites ( ) ;
}
} ,
nextPage : function ( ) {
Linkedin . debug ( 'find page' ) ;
Linkedin . setScroll ( ) ;
Linkedin . data . nextInterval = setInterval ( function ( ) {
var pagerButton = $ ( '.artdeco-pagination__button.artdeco-pagination__button--next[id^=ember]' ) ;
Linkedin . debug ( 'check page link' ) ;
if ( pagerButton . length === 0 ) {
return false ;
}
} ,
nextPage : function ( ) {
Linkedin . debug ( 'find page' ) ;
Linkedin . setScroll ( ) ;
Linkedin . data . nextInterval = setInterval ( function ( ) {
var pagerButton = $ ( '.artdeco-pagination__button.artdeco-pagination__button--next[id^=ember]' ) ;
Linkedin . debug ( 'check page link' ) ;
if ( pagerButton . length === 0 ) {
return false ;
}
clearInterval ( Linkedin . data . nextInterval ) ;
pagerButton . trigger ( 'click' ) ;
Linkedin . setDefaults ( ) ;
Linkedin . debug ( 'call next page' ) ;
Linkedin . checkRequest ( ) ;
} , Linkedin . config . pagerSpeed ) ;
} ,
checkRequest : function ( ) {
$ ( document ) . ajaxComplete ( function ( ) {
Linkedin . debug ( 'ready' ) ;
Linkedin . resetRequest ( ) ;
Linkedin . inspect ( ) ;
} ) ;
} ,
resetRequest : function ( ) {
this . debug ( 'reset request' ) ;
$ ( document ) . ajaxComplete ( function ( ) {
Linkedin . debug ( 'default request called' ) ;
} ) ;
} ,
setScroll : function ( a ) {
$ ( 'body' ) . click ( ) ;
window . scrollTo ( 0 , $ ( window ) . scrollTop ( ) + ( ( a ) ? a : Linkedin . config . scrollDownAuto ) ) ;
} ,
inspect : function ( ) {
this . debug ( 'inspect elements' ) ;
this . data . pageInterval = setInterval ( function ( ) {
Linkedin . setScroll ( Linkedin . config . scrollDownAuto ) ;
if ( Linkedin . totalRows ( ) >= 20 ) {
clearInterval ( Linkedin . data . pageInterval ) ;
Linkedin . sendInvites ( ) ;
} else {
Linkedin . debug ( 'listening..' ) ;
}
} , Linkedin . config . inspectorSpeed ) ;
clearInterval ( Linkedin . data . nextInterval ) ;
pagerButton . trigger ( 'click' ) ;
Linkedin . setDefaults ( ) ;
Linkedin . debug ( 'call next page' ) ;
Linkedin . checkRequest ( ) ;
} , Linkedin . config . pagerSpeed ) ;
} ,
checkRequest : function ( ) {
$ ( document ) . ajaxComplete ( function ( ) {
Linkedin . debug ( 'ready' ) ;
Linkedin . resetRequest ( ) ;
Linkedin . inspect ( ) ;
} ) ;
} ,
resetRequest : function ( ) {
this . debug ( 'reset request' ) ;
$ ( document ) . ajaxComplete ( function ( ) {
Linkedin . debug ( 'default request called' ) ;
} ) ;
} ,
closeAll : function ( ) {
if ( $ ( '.send-invite__cancel-btn' ) . length ) {
$ ( '.send-invite__cancel-btn' ) . click ( ) ;
}
} ) . init ( ) ;
return ( ! $ ( '.send-invite__cancel-btn:visible' ) . length ) ;
} ,
setScroll : function ( a ) {
$ ( 'body' ) . click ( ) ;
window . scrollTo ( 0 , $ ( window ) . scrollTop ( ) + ( ( a ) ? a : Linkedin . config . scrollDownAuto ) ) ;
} ,
inspect : function ( ) {
this . debug ( 'inspect elements' ) ;
this . data . pageInterval = setInterval ( function ( ) {
Linkedin . setScroll ( Linkedin . config . scrollDownAuto ) ;
if ( Linkedin . totalRows ( ) >= 20 ) {
clearInterval ( Linkedin . data . pageInterval ) ;
Linkedin . sendInvites ( ) ;
} else {
Linkedin . debug ( 'listening..' ) ;
}
} , Linkedin . config . inspectorSpeed ) ;
}
} ) . init ( ) ;