Skip to content

Commit ed5fae0

Browse files
Version 0.2.2
1 parent 6a9e72b commit ed5fae0

File tree

2 files changed

+21
-11
lines changed

2 files changed

+21
-11
lines changed

AdRework/Program.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,22 @@ private static string GetBetween(string Source, string Start, string End) {
142142
// fallback volume is the volume spotify should be set to if an error ever occurs and spotify gets stuck at no volume
143143
private static float FallbackVolume = 100f;
144144

145+
// if AdRework should always run all functions even if all related settings are disabled (more of a debug setting)
146+
private static bool ForceRun = false;
147+
148+
// ms interval AdRework should check for ads at
149+
private static int AdInterval = 100;
150+
// ms interval AdRework should perform an 'integrity check' at
151+
private static int IntegrityInterval = 450;
152+
145153
private static void LoadConfiguration() {
146154
try {
147155
string AppData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
148156

149157
if (!Directory.Exists($"{AppData}\\dmbk")) Directory.CreateDirectory($"{AppData}\\dmbk");
150158
if (!Directory.Exists($"{AppData}\\dmbk\\AdRework")) Directory.CreateDirectory($"{AppData}\\dmbk\\AdRework");
151159
if (!File.Exists($"{AppData}\\dmbk\\AdRework\\config.ini")) {
152-
File.WriteAllText($"{AppData}\\dmbk\\AdRework\\config.ini", "SkipAds='True'\nMuteAds='True'\nBypassAds='True'\nImmediateSkip='True'\nRegistryStartup='True'\nFallbackVolume='50'");
160+
File.WriteAllText($"{AppData}\\dmbk\\AdRework\\config.ini", "SkipAds='True'\nMuteAds='True'\nBypassAds='True'\nImmediateSkip='True'\nRegistryStartup='True'\nForceRun='False'\nFallbackVolume='50'\nAdInterval='100'\nIntegrityInterval='450'");
153161
return; }
154162

155163
try {
@@ -160,27 +168,29 @@ private static void LoadConfiguration() {
160168
BypassAds = bool.Parse(GetBetween(config, "BypassAds='", "'"));
161169
ImmediateSkip = bool.Parse(GetBetween(config, "ImmediateSkip='", "'"));
162170
RegistryStartup = bool.Parse(GetBetween(config, "RegistryStartup='", "'"));
163-
FallbackVolume = Convert.ToInt32(GetBetween(config, "FallbackVolume='", "'")); }
171+
ForceRun = bool.Parse(GetBetween(config, "ForceRun'", "'"));
172+
FallbackVolume = Convert.ToInt32(GetBetween(config, "FallbackVolume='", "'"));
173+
AdInterval = Convert.ToInt32(GetBetween(config, "AdInterval='", "'"));
174+
IntegrityInterval = Convert.ToInt32(GetBetween(config, "IntegrityInterval='", "'")); }
164175
catch (Exception) { // if reading config fails, reset it
165176
Console.WriteLine("failed to read config!");
166-
File.WriteAllText($"{AppData}\\dmbk\\AdRework\\config.ini", "# CONFIG RESET DUE TO LOADING ERROR\nSkipAds='True'\nMuteAds='True'\nBypassAds='True'\nImmediateSkip='True'\nRegistryStartup='True'\nFallbackVolume='50'"); }
177+
File.WriteAllText($"{AppData}\\dmbk\\AdRework\\config.ini", "SkipAds='True'\nMuteAds='True'\nBypassAds='True'\nImmediateSkip='True'\nRegistryStartup='True'\nForceRun='False'\nFallbackVolume='50'\nAdInterval='100'\nIntegrityInterval='450'"); }
167178
} catch (Exception) {}}
168179

169180
private static void IntegrityCheck(object sender, EventArgs e) {
170181
Process Spotify = Process.GetProcessesByName("Spotify").FirstOrDefault(p => !string.IsNullOrWhiteSpace(p.MainWindowTitle));
171-
Console.WriteLine(GetApplicationVolume(Spotify.Id));
172182
if (GetAdStatus() == SpotifyAdStatus.None && GetApplicationVolume(Spotify.Id) <= 0) SetApplicationVolume(Spotify.Id, FallbackVolume / 100); }
173183

174184
private static void AdReworkStart() {
175185
// load config
176186
LoadConfiguration();
177-
if (!SkipAds && !MuteAds && !BypassAds) Process.GetCurrentProcess().Kill(); // terminate if it has nothing to do
187+
if (!SkipAds && !MuteAds && !BypassAds && !ForceRun) Process.GetCurrentProcess().Kill(); // terminate if it has nothing to do
178188

179189
// start timer checking for ads every 100ms
180-
Timer timer = new Timer(100); timer.Elapsed += AutoAntiAd; timer.AutoReset = true; timer.Start();
190+
Timer timer = new Timer(AdInterval); timer.Elapsed += AutoAntiAd; timer.AutoReset = true; timer.Start();
181191
// make sure program isnt muted during songs every 235ms
182-
if (FallbackVolume > 0) {
183-
Timer integritycheck = new Timer(235); integritycheck.Elapsed += IntegrityCheck; integritycheck.AutoReset = true; integritycheck.Start(); }
192+
if (FallbackVolume > 0 || ForceRun) {
193+
Timer integritycheck = new Timer(IntegrityInterval); integritycheck.Elapsed += IntegrityCheck; integritycheck.AutoReset = true; integritycheck.Start(); }
184194

185195
// set program to start with windows
186196
CreateShortcut();

AdRework/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// General Information about an assembly is controlled through the following
66
// set of attributes. Change these attribute values to modify the information
77
// associated with an assembly.
8-
[assembly: AssemblyTitle("AdRework 0.2.1")]
8+
[assembly: AssemblyTitle("AdRework 0.2.2")]
99
[assembly: AssemblyDescription("Automatically and seamlessly skip spotify ads!")]
1010
[assembly: AssemblyConfiguration("")]
1111
[assembly: AssemblyCompany("dmbk development")]
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("0.2.1.0")]
36-
[assembly: AssemblyFileVersion("0.2.1.0")]
35+
[assembly: AssemblyVersion("0.2.2.0")]
36+
[assembly: AssemblyFileVersion("0.2.2.0")]

0 commit comments

Comments
 (0)