-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.js
executable file
·52 lines (48 loc) · 1.36 KB
/
install.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
#!/usr/bin/env node
var fs = require("fs");
var HOME_DIR = process.env.HOME || process.env.USERPROFILE;
var RC_FILE = HOME_DIR + "/.sjrc.js";
var TEMPLATE = (function(){
module.exports = {
"nogizhopaboroda.github.io/streamjockey": {
"play": function(){
console.log('play button pressed');
document.querySelector('#play_pause_button').click();
return true;
},
"pause": function(){
console.log('pause button pressed');
document.querySelector('#play_pause_button').click();
return false;
},
"next": function(){
console.log('next button pressed');
document.querySelector('#next_button').click();
return true;
},
"prev": function(){
console.log('prev button pressed');
document.querySelector('#prev_button').click();
return true;
},
"is_playing": function(){
return document
.querySelector('#play_pause_button')
.classList
.contains('is-playing');
}
}
}
})
.toString()
.replace(/function.*\{([\s\S]+)\}$/ig, "$1");
fs.stat(RC_FILE, function(err, stats){
if(!err){
console.log('rc file already exists');
return;
}
fs.writeFile(RC_FILE, TEMPLATE, 'utf8', (error) => {
if (error) throw err;
console.log('RC file created: '.concat(RC_FILE));
});
});