-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
43 lines (37 loc) · 1.09 KB
/
Copy pathindex.js
File metadata and controls
43 lines (37 loc) · 1.09 KB
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
const views = require("./tools/views")
const favorites = require("./tools/favorites")
const readline = require('node:readline')
const { stdin: input, stdout: output } = require('node:process')
const rl = readline.createInterface({ input, output })
let getOption = (url) => rl.question('[1] Add Views\n[2] Add Favorites\n[3] Both\n\nWhich mode you like? ', (option) => {
console.clear()
switch (option) {
case '1':
views(url)
rl.close();
break;
case '2':
favorites(url)
rl.close()
break;
case '3':
views(url)
favorites(url)
rl.close()
break;
default:
console.log('Unknown option.\n')
getOption(url)
break;
}
})
let getUrl = () => rl.question('Please input valid tiktok video url: ', (url) => {
console.clear()
if (!/^(https?:\/\/)?(vt\.tiktok\.com\/[\w]+)(\/)?$/.test(url)) {
console.log('Invalid Tiktok Url Video.\n')
return getUrl()
}
getOption(url)
})
console.clear()
getUrl()