-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
41 lines (41 loc) · 1.14 KB
/
main.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
(function(){
'use strict';
var fs = require('fs');
function HearthStoneLogger(){
var that = {},
configFile = 'log.config',
getDataLocation = function(){
return 'C:/Program Files (x86)/Hearthstone/Hearthstone_Data/output_log.txt';
},
getConfigLocation = function(){
return process.env.LOCALAPPDATA+'/Blizzard/Hearthstone/'+configFile;
},
configExist = function(){
return fs.existsSync(getConfigLocation());
},
createConfig = function(callback){
if (configExist()) return;
fs.renameSync(process.cwd()+'/'+configFile, getConfigLocation());
},
parseEvents = function(line){
if (line.toLowerCase().indexOf('victory_screen_start')!==-1){
alert('yo win yourself a horse');
}
if (line.toLowerCase().indexOf('defeat_screen_start')!==-1){
alert('yo lost yo game');
}
console.log(line);
},
monitorChanges = function(){
var ft = require('file-tail').startTailing(getDataLocation());
ft.on('line',parseEvents);
}
;
that.monitorChanges = monitorChanges;
that.createConfig = createConfig;
return that;
}
var hearth = new HearthStoneLogger();
hearth.createConfig();
hearth.monitorChanges();
})();