Add location options

This commit is contained in:
Jack 2023-09-14 23:03:19 -04:00
parent c2cf342f39
commit b52f29ea74
8 changed files with 96 additions and 21 deletions

View File

@ -31,6 +31,12 @@
<setting name="DelayMax" serializeAs="String"> <setting name="DelayMax" serializeAs="String">
<value>15</value> <value>15</value>
</setting> </setting>
<setting name="ChooseType" serializeAs="String">
<value>Hashtags</value>
</setting>
<setting name="Instagram_Locations" serializeAs="String">
<value>249859506/dominican-republic</value>
</setting>
</AutoLikerCefSharpWpf.Properties.Settings> </AutoLikerCefSharpWpf.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

View File

@ -192,7 +192,7 @@ alObject.prototype.instagramLoopOverPostsClick = function(index) {
} else { } else {
// already liked, go to the next item // already liked, go to the next item
thisObj.log(" - already liked this post!"); thisObj.log(" - already liked this post!");
thisObj.instagramClickNextButton(nextBtn, index); thisObj.instagramClickNextButton(nextBtn, (index - 1));
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -15,7 +15,17 @@ namespace AutoLikerCefSharpWpf.Helper
private void InitializeSettings() private void InitializeSettings()
{ {
if (Properties.Settings.Default.ChooseType.Equals(main.rdTypeLocationTag.Name))
{
main.rdTypeLocationTag.IsChecked = true;
main.rdTypeHashTag.IsChecked = false;
} else
{
main.rdTypeHashTag.IsChecked = true;
main.rdTypeLocationTag.IsChecked = false;
}
main.txtHashTag.Text = Properties.Settings.Default.Instagram_Hashtag; main.txtHashTag.Text = Properties.Settings.Default.Instagram_Hashtag;
main.txtLocationTag.Text = Properties.Settings.Default.Instagram_Locations;
main.txtDelayRestartMin.Text = Properties.Settings.Default.DelayRestartMin.ToString(); main.txtDelayRestartMin.Text = Properties.Settings.Default.DelayRestartMin.ToString();
main.txtDelayRestartMax.Text = Properties.Settings.Default.DelayRestartMax.ToString(); main.txtDelayRestartMax.Text = Properties.Settings.Default.DelayRestartMax.ToString();
main.txtMaxLikesMin.Text = Properties.Settings.Default.LikesMin.ToString(); main.txtMaxLikesMin.Text = Properties.Settings.Default.LikesMin.ToString();
@ -25,19 +35,31 @@ namespace AutoLikerCefSharpWpf.Helper
this.ToggleSettingsSaveButton(false); this.ToggleSettingsSaveButton(false);
// assign handlers // assign handlers
main.txtHashTag.TextChanged += Al_Settings_TextChanged; main.rdTypeHashTag.Checked += RadioButtonChanged;
main.txtDelayRestartMin.TextChanged += Al_Settings_TextChanged; main.rdTypeHashTag.Unchecked += RadioButtonChanged;
main.txtDelayRestartMax.TextChanged += Al_Settings_TextChanged; main.rdTypeLocationTag.Checked += RadioButtonChanged;
main.txtMaxLikesMin.TextChanged += Al_Settings_TextChanged; main.rdTypeLocationTag.Unchecked += RadioButtonChanged;
main.txtMaxLikesMax.TextChanged += Al_Settings_TextChanged; main.txtHashTag.TextChanged += TextFieldChanged;
main.txtDelayMin.TextChanged += Al_Settings_TextChanged; main.txtLocationTag.TextChanged += TextFieldChanged;
main.txtDelayMax.TextChanged += Al_Settings_TextChanged; main.txtDelayRestartMin.TextChanged += TextFieldChanged;
main.txtDelayRestartMax.TextChanged += TextFieldChanged;
main.txtMaxLikesMin.TextChanged += TextFieldChanged;
main.txtMaxLikesMax.TextChanged += TextFieldChanged;
main.txtDelayMin.TextChanged += TextFieldChanged;
main.txtDelayMax.TextChanged += TextFieldChanged;
} }
private void Al_Settings_TextChanged(object sender, System.Windows.Controls.TextChangedEventArgs e) private void RadioButtonChanged(object sender, System.Windows.RoutedEventArgs e)
{
RadioButton rdBtn = sender as RadioButton;
Debug.WriteLine($"Setting changed: Radio button '{rdBtn.Name}' checked={rdBtn.IsChecked}");
this.ToggleSettingsSaveButton(true);
}
private void TextFieldChanged(object sender, TextChangedEventArgs e)
{ {
TextBox tb = (TextBox)sender; TextBox tb = (TextBox)sender;
Debug.WriteLine("Setting changed: " + tb.Name + " = " + tb.Text); Debug.WriteLine($"Setting changed: {tb.Name} = {tb.Text}");
this.ToggleSettingsSaveButton(true); this.ToggleSettingsSaveButton(true);
} }
@ -62,7 +84,15 @@ namespace AutoLikerCefSharpWpf.Helper
int.TryParse(main.txtDelayMin.Text, out int delayMin); int.TryParse(main.txtDelayMin.Text, out int delayMin);
int.TryParse(main.txtDelayMax.Text, out int delayMax); int.TryParse(main.txtDelayMax.Text, out int delayMax);
if ((bool) main.rdTypeLocationTag.IsChecked)
{
Properties.Settings.Default.ChooseType = main.rdTypeLocationTag.Name;
} else
{
Properties.Settings.Default.ChooseType = main.rdTypeHashTag.Name;
}
Properties.Settings.Default.Instagram_Hashtag = main.txtHashTag.Text; Properties.Settings.Default.Instagram_Hashtag = main.txtHashTag.Text;
Properties.Settings.Default.Instagram_Locations = main.txtLocationTag.Text;
Properties.Settings.Default.DelayRestartMin = delayRestartMin; Properties.Settings.Default.DelayRestartMin = delayRestartMin;
Properties.Settings.Default.DelayRestartMax = delayRestartMax; Properties.Settings.Default.DelayRestartMax = delayRestartMax;
Properties.Settings.Default.LikesMin = likesMin; Properties.Settings.Default.LikesMin = likesMin;

View File

@ -5,7 +5,7 @@
TextElement.Foreground="{DynamicResource MaterialDesignBody}" TextElement.Foreground="{DynamicResource MaterialDesignBody}"
Background="{DynamicResource MaterialDesignPaper}" Background="{DynamicResource MaterialDesignPaper}"
TextElement.FontWeight="Medium" TextElement.FontWeight="Medium"
TextElement.FontSize="14" TextElement.FontSize="12"
FontFamily="{materialDesign:MaterialDesignFont}" FontFamily="{materialDesign:MaterialDesignFont}"
xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
xmlns:cef="clr-namespace:CefSharp;assembly=CefSharp.Core" xmlns:cef="clr-namespace:CefSharp;assembly=CefSharp.Core"
@ -39,8 +39,8 @@
<Label Grid.Row="4" Grid.Column="0" Content="Delay range between likes (sec)" x:Name="lblDelay" /> <Label Grid.Row="4" Grid.Column="0" Content="Delay range between likes (sec)" x:Name="lblDelay" />
<Label Grid.Row="5" Grid.Column="0" Content="Delay before reloading (min)" x:Name="lblDelayRestart" /> <Label Grid.Row="5" Grid.Column="0" Content="Delay before reloading (min)" x:Name="lblDelayRestart" />
<StackPanel Grid.Column="1" Grid.Row="0" Margin="3" HorizontalAlignment="Left" Orientation="Vertical"> <StackPanel Grid.Column="1" Grid.Row="0" Margin="3" HorizontalAlignment="Left" Orientation="Vertical">
<RadioButton x:Name="radTypeHashTag" GroupName="grpTypeButtons" IsChecked="True" Foreground="White">Hashtags</RadioButton> <RadioButton x:Name="rdTypeHashTag" GroupName="grpTypeButtons" IsChecked="True" Foreground="White">Hashtags</RadioButton>
<RadioButton x:Name="radTypeLocationTag" GroupName="grpTypeButtons" Foreground="White">Location</RadioButton> <RadioButton x:Name="rdTypeLocationTag" GroupName="grpTypeButtons" Foreground="White">Locations</RadioButton>
</StackPanel> </StackPanel>
<TextBox Grid.Column="1" Grid.Row="1" Margin="3" Height="50px" TextWrapping="Wrap" x:Name="txtHashTag"/> <TextBox Grid.Column="1" Grid.Row="1" Margin="3" Height="50px" TextWrapping="Wrap" x:Name="txtHashTag"/>
<TextBox Grid.Column="1" Grid.Row="2" Margin="3" Height="50px" TextWrapping="Wrap" x:Name="txtLocationTag"/> <TextBox Grid.Column="1" Grid.Row="2" Margin="3" Height="50px" TextWrapping="Wrap" x:Name="txtLocationTag"/>
@ -59,7 +59,7 @@
<Label Content="-" /> <Label Content="-" />
<TextBox Width="40" x:Name="txtDelayRestartMax" /> <TextBox Width="40" x:Name="txtDelayRestartMax" />
</StackPanel> </StackPanel>
<Button Grid.Column="1" Grid.Row="6" HorizontalAlignment="Center" MinWidth="80" Margin="3" Content="Save" x:Name="btnSaveSettings" Click="BtnSaveSettings_Click"/> <Button Grid.Column="1" Grid.Row="6" HorizontalAlignment="Left" MinWidth="80" Margin="3" Content="Save" x:Name="btnSaveSettings" Click="BtnSaveSettings_Click"/>
</Grid> </Grid>
<StackPanel DockPanel.Dock="Top" HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 5"> <StackPanel DockPanel.Dock="Top" HorizontalAlignment="Left" Orientation="Horizontal" Margin="0 5">
<Button x:Name="btnStart" Height="35" Content="Start" Margin="5 0 0 0" Click="BtnStart_Click"/> <Button x:Name="btnStart" Height="35" Content="Start" Margin="5 0 0 0" Click="BtnStart_Click"/>

View File

@ -21,7 +21,7 @@ namespace AutoLikerCefSharpWpf
InitializeComponent(); InitializeComponent();
// version // version
this.AutoLikerVersion = "v2.0.2-20230914"; this.AutoLikerVersion = "v2.0.3-20230914";
this.DataContext = this; this.DataContext = this;
// manage settings in UI // manage settings in UI
this._alsm = new AutoLikerSettingsManager(this); this._alsm = new AutoLikerSettingsManager(this);
@ -75,7 +75,6 @@ namespace AutoLikerCefSharpWpf
await CefSharp.BindObjectAsync(""boundAsync""); await CefSharp.BindObjectAsync(""boundAsync"");
//The default is to camel case method names (the first letter of the method name is changed to lowercase) //The default is to camel case method names (the first letter of the method name is changed to lowercase)
boundAsync.logMessage(""This is a boundAsync test"");
console.log('boundAsync worked!'); console.log('boundAsync worked!');
})();"; })();";
args.Frame.ExecuteJavaScriptAsync(script); args.Frame.ExecuteJavaScriptAsync(script);
@ -90,6 +89,12 @@ namespace AutoLikerCefSharpWpf
this.Dispatcher.Invoke(() => this.Dispatcher.Invoke(() =>
{ {
// check which option to use
string paramTag = this.txtHashTag.Text;
if ((bool) this.rdTypeLocationTag.IsChecked)
{
paramTag = this.txtLocationTag.Text;
}
// Execute script // Execute script
string alStartScript = $@"(function() string alStartScript = $@"(function()
{{ {{
@ -161,8 +166,13 @@ namespace AutoLikerCefSharpWpf
this.Dispatcher.Invoke(() => this.Dispatcher.Invoke(() =>
{ {
this.txtLog.Clear(); this.txtLog.Clear();
// get hashtag string URL = "https://www.instagram.com/explore/tags/";
string hashtag = this.txtHashTag.Text; string hashtag = this.txtHashTag.Text;
if ((bool) this.rdTypeLocationTag.IsChecked)
{
URL = "https://www.instagram.com/explore/locations/";
hashtag = this.txtLocationTag.Text;
}
// check if multiple hastags // check if multiple hastags
if (hashtag.Contains(",")) if (hashtag.Contains(","))
{ {
@ -176,9 +186,8 @@ namespace AutoLikerCefSharpWpf
} }
this.LogMessage("Load Instagram Tag: " + hashtag); this.LogMessage("Load Instagram Tag: " + hashtag);
// create URL // create URL
string URL = "https://www.instagram.com/explore/tags/" + hashtag + "/#al"; URL += hashtag + "/#al";
// reload browser // load URL
//this.browser.Address = URL;
this.Browser.Load(URL); this.Browser.Load(URL);
}); });
} }

View File

@ -106,5 +106,29 @@ namespace AutoLikerCefSharpWpf.Properties {
this["DelayMax"] = value; this["DelayMax"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Hashtags")]
public string ChooseType {
get {
return ((string)(this["ChooseType"]));
}
set {
this["ChooseType"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("249859506/dominican-republic")]
public string Instagram_Locations {
get {
return ((string)(this["Instagram_Locations"]));
}
set {
this["Instagram_Locations"] = value;
}
}
} }
} }

View File

@ -23,5 +23,11 @@
<Setting Name="DelayMax" Type="System.Int32" Scope="User"> <Setting Name="DelayMax" Type="System.Int32" Scope="User">
<Value Profile="(Default)">15</Value> <Value Profile="(Default)">15</Value>
</Setting> </Setting>
<Setting Name="ChooseType" Type="System.String" Scope="User">
<Value Profile="(Default)">Hashtags</Value>
</Setting>
<Setting Name="Instagram_Locations" Type="System.String" Scope="User">
<Value Profile="(Default)">249859506/dominican-republic</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>