-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
189 lines (175 loc) · 8.44 KB
/
Program.cs
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
#region TikTok LIVE Cleaner
#region Imports
using System.Diagnostics;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Text.Json;
using TikTokLIVECleaner;
#endregion
#region Program
internal class Program
{
#region Main
private static void Main(string[] args)
{
#region Main Null Check
if (args is null)
{
throw new ArgumentNullException(nameof(args));
}
#endregion
#region Methods
Startup();
#endregion
}
#endregion
#region Startup
public static void Startup()
{
/*string currdir = System.IO.Directory.GetCurrentDirectory();
string finalpath = currdir + "\\tiktok_cleaner.json";
if (!File.Exists(finalpath))
{
try
{
using (FileStream fs = new FileStream(finalpath, FileMode.CreateNew))
{
byte[] content = System.Text.Encoding.UTF8.GetBytes("{\r\n \"welcome\": \"TikTok LIVE Cleaner\",\r\n \"color\": \"White\"\r\n}");
fs.Write(content, 0, content.Length);
}
Console.WriteLine("File created successfully at " + finalpath);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
else
{
Console.WriteLine("File already exists at " + finalpath);
}
String jsonString = new StreamReader(finalpath).ReadToEnd();
var tikTokLiveCleaner = TikTokLiveCleaner.FromJson(jsonString);
string color = tikTokLiveCleaner.Color;*/
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("░▀█▀░▀█▀░█░█░▀█▀░█▀█░█░█░░░█▀▀░▀█▀░█░█░█▀▄░▀█▀░█▀█░░░█▀█░█▀█░▀█▀░▀█▀░█▄█░▀█▀░▀▀█░█▀▀░█▀▄\r\n░░█░░░█░░█▀▄░░█░░█░█░█▀▄░░░▀▀█░░█░░█░█░█░█░░█░░█░█░░░█░█░█▀▀░░█░░░█░░█░█░░█░░▄▀░░█▀▀░█▀▄\r\n░░▀░░▀▀▀░▀░▀░░▀░░▀▀▀░▀░▀░░░▀▀▀░░▀░░▀▀▀░▀▀░░▀▀▀░▀▀▀░░░▀▀▀░▀░░░░▀░░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀░▀");
Console.WriteLine("\n");
Thread.Sleep(1000);
Console.WriteLine("Welcome to the TikTok LIVE Studio Optimizer!\n");
Console.WriteLine("Press Space to start.");
Console.WriteLine("Press Escape to exit.\n");
ConsoleKeyInfo key = Console.ReadKey();
if (key.Key == ConsoleKey.Spacebar)
{
ClearWatchDog();
Thread.Sleep(2000);
Console.Clear();
Console.WriteLine("░▀█▀░▀█▀░█░█░▀█▀░█▀█░█░█░░░█▀▀░▀█▀░█░█░█▀▄░▀█▀░█▀█░░░█▀█░█▀█░▀█▀░▀█▀░█▄█░▀█▀░▀▀█░█▀▀░█▀▄\r\n░░█░░░█░░█▀▄░░█░░█░█░█▀▄░░░▀▀█░░█░░█░█░█░█░░█░░█░█░░░█░█░█▀▀░░█░░░█░░█░█░░█░░▄▀░░█▀▀░█▀▄\r\n░░▀░░▀▀▀░▀░▀░░▀░░▀▀▀░▀░▀░░░▀▀▀░░▀░░▀▀▀░▀▀░░▀▀▀░▀▀▀░░░▀▀▀░▀░░░░▀░░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀░▀");
Console.WriteLine("\n");
Console.WriteLine("Starting TikTok LIVE Studio Optimizer...");
Thread.Sleep(3000);
Console.Clear();
Console.WriteLine("░▀█▀░▀█▀░█░█░▀█▀░█▀█░█░█░░░█▀▀░▀█▀░█░█░█▀▄░▀█▀░█▀█░░░█▀█░█▀█░▀█▀░▀█▀░█▄█░▀█▀░▀▀█░█▀▀░█▀▄\r\n░░█░░░█░░█▀▄░░█░░█░█░█▀▄░░░▀▀█░░█░░█░█░█░█░░█░░█░█░░░█░█░█▀▀░░█░░░█░░█░█░░█░░▄▀░░█▀▀░█▀▄\r\n░░▀░░▀▀▀░▀░▀░░▀░░▀▀▀░▀░▀░░░▀▀▀░░▀░░▀▀▀░▀▀░░▀▀▀░▀▀▀░░░▀▀▀░▀░░░░▀░░▀▀▀░▀░▀░▀▀▀░▀▀▀░▀▀▀░▀░▀");
Console.WriteLine("\n");
Console.WriteLine("Listening for any process containing the name 'TikTok LIVE Studio'...");
Console.WriteLine("\n");
GetRunTime();
}
else if (key.Key == ConsoleKey.Escape)
{
Environment.Exit(0);
}
}
#endregion
#region ClearWatchDog
public static void ClearWatchDog()
{
try
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string finalpath = Path.Combine(path, "TikTok LIVE Studio", "watchdog");
foreach (string cache in Directory.EnumerateDirectories(finalpath))
{
Directory.Delete(cache, true);
Console.WriteLine("\n");
Console.WriteLine("Successfully deleted the folder at: " + cache);
}
} catch(Exception)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
string finalpath = Path.Combine(path, "TikTok LIVE Studio", "watchdog");
Console.WriteLine("Couldn't find TikTok Live Studio!");
Console.WriteLine("An error occured looking for: "+ finalpath);
Environment.Exit(0);
}
}
#endregion
#region GetRunTime
public static void GetRunTime()
{
try
{
bool GetRuntimeBool = true;
while (GetRuntimeBool)
{
Process[] pname = Process.GetProcessesByName("TikTok LIVE Studio");
if (pname.Length > 0)
{
foreach (var processr in pname)
{
Console.WriteLine("\nFound one!\n" + "Process ID: " + processr.Id + " | Process Name: " + processr.ProcessName);
}
Console.WriteLine("\n");
Console.WriteLine("TikTok LIVE Studio is running with the PID: {0}", pname[0].Id);
if (pname.Length != 0)
{
Process process = Process.GetProcessById(pname[0].Id);
if (process != null)
{
process.WaitForExit();
ClearWatchDog();
Console.WriteLine("TikTok LIVE Studio has been terminated"); // Might error as pname[0] may not exist at this time
}
}
Thread.Sleep(10);
}
}
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
/*public static string settings()
{
string currdir = System.IO.Directory.GetCurrentDirectory();
string finalpath = currdir + "\\tiktok_cleaner.json";
if (!File.Exists(finalpath))
{
try
{
using (FileStream fs = new FileStream(finalpath, FileMode.CreateNew))
{
byte[] content = System.Text.Encoding.UTF8.GetBytes("{\r\n \"welcome\": \"TikTok LIVE Cleaner\",\r\n \"color\": \"9\"\r\n}");
fs.Write(content, 0, content.Length);
}
Console.WriteLine("File created successfully at " + finalpath);
}
catch (Exception e)
{
Console.WriteLine(e);
}
}
else
{
Console.WriteLine("File already exists at " + finalpath);
}
String jsonString = new StreamReader(finalpath).ReadToEnd();
var tikTokLiveCleaner = TikTokLiveCleaner.FromJson(jsonString);
string color = tikTokLiveCleaner.Color;
return color;
}*/
}
#endregion
#endregion
#endregion