-
Notifications
You must be signed in to change notification settings - Fork 0
/
mess.js
60 lines (48 loc) · 1.63 KB
/
mess.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var casper = require('casper').create({
pageSettings: {
loadImages: false,//The script is much faster when this field is set to false
loadPlugins: false,
userAgent: 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36'
},
verbose : true,
logLevel : 'info',
});
/**
* Configuration here
*/
var login_username = "#username@yahoo.com";
var login_password = "#password";
//person suppose to talk
var talkTo_username = "#person";
/**
* Everything starts here!
*/
casper.start('https://www.messenger.com', function() {
// The pretty HUGE viewport allows for to have a big rezolution of printscreen.
this.viewport(1900,1000);
//login with your account
this.evaluate(function(username, password){
document.querySelector('input[type="text"]').value = username;
document.querySelector('input[type="password"]').value = password;
document.querySelector('button[type="submit"]').click();
}, login_username, login_password);
});
casper.thenOpen("https://www.messenger.com/t/"+talkTo_username, function(){
});
casper.then(function() {
this.clickLabel('Change Color', 'div');
});
casper.then(function() {
//random color selected
this.evaluate(function() {
var color = document.querySelectorAll('div._5dr4')[Math.floor((Math.random() * 18) + 1)];
color.click();
})
//take picture to check if you are logged
casper.waitForSelector('a[title="Conversation Information"]', function () {
this.capture("photo+index.png");
});
});
casper.run(function(){
this.exit();
});