diff --git a/AutoLikerCefSharpWpf/App.config b/AutoLikerCefSharpWpf/App.config index ad4a485..1c19c3f 100644 --- a/AutoLikerCefSharpWpf/App.config +++ b/AutoLikerCefSharpWpf/App.config @@ -31,6 +31,12 @@ 15 + + Hashtags + + + 249859506/dominican-republic + \ No newline at end of file diff --git a/AutoLikerCefSharpWpf/Assets/autotag_injection.js b/AutoLikerCefSharpWpf/Assets/autotag_injection.js index 076ffc6..7d4228c 100644 --- a/AutoLikerCefSharpWpf/Assets/autotag_injection.js +++ b/AutoLikerCefSharpWpf/Assets/autotag_injection.js @@ -192,7 +192,7 @@ alObject.prototype.instagramLoopOverPostsClick = function(index) { } else { // already liked, go to the next item thisObj.log(" - already liked this post!"); - thisObj.instagramClickNextButton(nextBtn, index); + thisObj.instagramClickNextButton(nextBtn, (index - 1)); } } diff --git a/AutoLikerCefSharpWpf/Assets/autotag_injection_min.js b/AutoLikerCefSharpWpf/Assets/autotag_injection_min.js index 97cc576..99283d1 100644 --- a/AutoLikerCefSharpWpf/Assets/autotag_injection_min.js +++ b/AutoLikerCefSharpWpf/Assets/autotag_injection_min.js @@ -1 +1 @@ -function alObject() { this._tag = "", this._posts = {}, this._maxLikes = 3, this._likesMin = 5, this._likesMax = 10, this._delayRestart = 15, this._delayRestartMin = 15, this._delayRestartMax = 30, this._delayPerLikeMin = 5, this._delayPerLikeMax = 10, this._endCursor = "", this._failedRetriesMax = 2, this._failedRetries = 0, this._instagramBaseUrl = "https://www.instagram.com", this._postItems = [], this._scrollOffset = null } alObject.prototype.initializeSettings = function (t, e, o, s, l, n, i) { if (this._tag = t, this._likesMin = e, this._likesMax = o, this._delayPerLikeMin = s, this._delayPerLikeMax = l, this._delayRestartMin = n, this._delayRestartMax = i, console.log("tag:" + t + " | likesMin:" + e + " | likesMax:" + o + " | delayMin: " + s + " | delayMax: " + l + " | delayRestartMin: " + n + " | delayRestartMax: " + i), this._maxLikes = this.getRandomInt(this._likesMin, this._likesMax), this._delayRestart = this.getRandomInt(this._delayRestartMin, this._delayRestartMax), console.log("_maxLikes: " + this._maxLikes), console.log("_delayRestart (min): " + this._delayRestart), this._tag.includes(",")) { let t = this._tag.split(","); console.log(t), console.log("tags length: " + t.length); i = this.getRandomInt(0, t.length - 1), i = t[i].trim(); console.log("picked tag: " + i), this._tag = i } }, alObject.prototype.instagramStartClickProcess = function (s = !0) { var r = this; r._postItems = [], console.log("*** instagramStartClickProcess ***"), window.scrollTo(0, 0), r.runDelay(1e4, () => { r.log((new Date).toLocaleString() + ": Starting click process .."); var t = jQuery("h2").eq(0), e = jQuery("h2").eq(1); let o = null; if (0 < e.length ? o = e : 0 == e.length && 0 < t.length && (o = t), null == o || 0 == o) r.log("ERROR: couldn't find most recent or top posts sections!"), s ? (r.log(" - retrying after 60 seconds (to give IG time to load)."), r.runDelay(6e4, () => { r.instagramStartClickProcess(!1) })) : r.runDelay(1e3, () => { r.restartProcess() }); else { let i = o.next(); r.log("Scroll to list .."), jQuery("html, body").animate({ scrollTop: i.offset().top }, 500); var t = i.offset().left, a = i.offset().top; r._scrollOffset = i.offset(), console.log("parentX: " + t + " ; parentY: " + a), r.runDelay(2e3, () => { let t = i.children("div").eq(0), e = t.find("a"); e.each(function (t) { r._postItems.push(jQuery(this).attr("href")) }), console.log("items:"), console.log(r._postItems), r.log("Found posts: " + r._postItems.length); let o = jQuery('a[href="' + r._postItems[0] + '"]'); console.log(o); let s = o.find("img").eq(0); var l, n; console.log(s), console.log(s.attr("src")), s && (console.log("imgX: " + s.offset().left + " ; imgY: " + s.offset().top), l = parseInt(s.offset().left) + 30, n = parseInt(a - s.offset().top) + 60, console.log("clickX: " + l + " ; clickY: " + n), r.log("Will like this many posts: " + r._maxLikes), r.instagramClickPost(s, l, n)) }) } }) }, alObject.prototype.instagramClickPost = function (t, e, o) { var s = this; s.log("Click on initial post .."), boundAsync.singleLeftClick(e, o).then(t => { console.log("Left Click"), s.runDelay(8e3, () => { s.instagramLoopOverPostsClick() }) }) }, alObject.prototype.instagramLoopOverPostsClick = function (e) { var o = this; e = e || 1, o.log("Like post; " + e + " of " + o._maxLikes); let t = jQuery("body").find("span._aamw span:has(svg)").eq(0); console.log("likeBtn:"), console.log(t); var s = jQuery("div._aaqg button._abl-"); console.log("nextBtn:"), console.log(s), 0 == t.length && (o.log(' - Could not find the "Like" button :('), 0 < s.length ? o.instagramClickNextButton(s, e) : o.restartProcess()); var l = t.offset(), n = parseInt(l.top - jQuery(window).scrollTop()), i = parseInt(l.left - jQuery(window).scrollLeft()); console.log("likeBtn = clickX: " + i + " ; clickY: " + n); let a = t.find("svg").eq(0); var r, c = a.attr("aria-label"); console.log("Like Text: " + c), "Like" === c ? (l = 1e3 * (r = o.getRandomInt(o._delayPerLikeMin, o._delayPerLikeMax)), o.log(" - not liked yet; delay before clicking like = " + r + " sec"), o.runDelay(l, () => { o.log(" - initiating clicking Like button .."), boundAsync.singleLeftClick(i + 10, n + 10).then(t => { o.log(" - clicked Like button .. wait to confirm .."), o.runDelay(4e3, () => { c = jQuery("body").find("span._aamw svg").eq(0).attr("aria-label"), console.log("Like Text: " + c), "Like" !== c ? (o.log(" - Successfully liked!"), o.instagramClickNextButton(s, e)) : (o.log(" - POST NOT LIKED! BLOCKED??"), o.log("*** STOPPING ***"), o.restartProcess()) }) }, t => { o.log(" - Error liking! Reason = " + t), o.instagramClickNextButton(s, e) }) })) : (o.log(" - already liked this post!"), o.instagramClickNextButton(s, e)) }, alObject.prototype.instagramClickNextButton = function (t, e) { var o, s, l = this; e < l._maxLikes ? (l.log(" - Waiting before clicking on next button .."), t = t.offset(), console.log(t), o = parseInt(t.top - jQuery(window).scrollTop()), s = parseInt(t.left - jQuery(window).scrollLeft()), console.log("nextBtn = nextX: " + s + " ; nextY: " + o), l.runDelay(3e3, () => { boundAsync.singleLeftClick(s + 10, o + 10).then(t => { l.log(" - Successfully went to the next post! Wait 5 sec .."), l.runDelay(5e3, () => { var t = e + 1; l.instagramLoopOverPostsClick(t) }) }, t => { l.log(" - Error going to the next post! Reason = " + t) }) })) : (l.log(" - Reached end of list of posts, restarting process .."), l.runDelay(3e3, () => { l.restartProcess() })) }, alObject.prototype.restartProcess = function () { var o = this; if (console.log("*** restartProcess ***"), boundAsync) { let t; t = o._delayRestart || 15; var s = 6e4 * t; let e = new Date; var l = new Date(e.getTime() + s); o.log(e.toLocaleString() + ": RESTARTING in (min): " + t), o.log(" - Reloading at: " + l.toLocaleString()), o.runDelay(s, () => { boundAsync.restartProcess().then(t => { console.log("reloading ..") }) }) } }, alObject.prototype.runDelay = function (t, e) { setTimeout(e, t) }, alObject.prototype.log = function (t) { console.log(t), boundAsync && boundAsync.logMessage(t).then(t => { }, t => { console.error(t) }) }, alObject.prototype.getRandomInt = function (t, e) { return Math.floor(Math.random() * (e - t + 1)) + t }; \ No newline at end of file +function alObject() { this._tag = "", this._posts = {}, this._maxLikes = 3, this._likesMin = 5, this._likesMax = 10, this._delayRestart = 15, this._delayRestartMin = 15, this._delayRestartMax = 30, this._delayPerLikeMin = 5, this._delayPerLikeMax = 10, this._endCursor = "", this._failedRetriesMax = 2, this._failedRetries = 0, this._instagramBaseUrl = "https://www.instagram.com", this._postItems = [], this._scrollOffset = null } alObject.prototype.initializeSettings = function (t, e, o, s, l, n, i) { if (this._tag = t, this._likesMin = e, this._likesMax = o, this._delayPerLikeMin = s, this._delayPerLikeMax = l, this._delayRestartMin = n, this._delayRestartMax = i, console.log("tag:" + t + " | likesMin:" + e + " | likesMax:" + o + " | delayMin: " + s + " | delayMax: " + l + " | delayRestartMin: " + n + " | delayRestartMax: " + i), this._maxLikes = this.getRandomInt(this._likesMin, this._likesMax), this._delayRestart = this.getRandomInt(this._delayRestartMin, this._delayRestartMax), console.log("_maxLikes: " + this._maxLikes), console.log("_delayRestart (min): " + this._delayRestart), this._tag.includes(",")) { let t = this._tag.split(","); console.log(t), console.log("tags length: " + t.length); i = this.getRandomInt(0, t.length - 1), i = t[i].trim(); console.log("picked tag: " + i), this._tag = i } }, alObject.prototype.instagramStartClickProcess = function (s = !0) { var r = this; r._postItems = [], console.log("*** instagramStartClickProcess ***"), window.scrollTo(0, 0), r.runDelay(1e4, () => { r.log((new Date).toLocaleString() + ": Starting click process .."); var t = jQuery("h2").eq(0), e = jQuery("h2").eq(1); let o = null; if (0 < e.length ? o = e : 0 == e.length && 0 < t.length && (o = t), null == o || 0 == o) r.log("ERROR: couldn't find most recent or top posts sections!"), s ? (r.log(" - retrying after 60 seconds (to give IG time to load)."), r.runDelay(6e4, () => { r.instagramStartClickProcess(!1) })) : r.runDelay(1e3, () => { r.restartProcess() }); else { let i = o.next(); r.log("Scroll to list .."), jQuery("html, body").animate({ scrollTop: i.offset().top }, 500); var t = i.offset().left, a = i.offset().top; r._scrollOffset = i.offset(), console.log("parentX: " + t + " ; parentY: " + a), r.runDelay(2e3, () => { let t = i.children("div").eq(0), e = t.find("a"); e.each(function (t) { r._postItems.push(jQuery(this).attr("href")) }), console.log("items:"), console.log(r._postItems), r.log("Found posts: " + r._postItems.length); let o = jQuery('a[href="' + r._postItems[0] + '"]'); console.log(o); let s = o.find("img").eq(0); var l, n; console.log(s), console.log(s.attr("src")), s && (console.log("imgX: " + s.offset().left + " ; imgY: " + s.offset().top), l = parseInt(s.offset().left) + 30, n = parseInt(a - s.offset().top) + 60, console.log("clickX: " + l + " ; clickY: " + n), r.log("Will like this many posts: " + r._maxLikes), r.instagramClickPost(s, l, n)) }) } }) }, alObject.prototype.instagramClickPost = function (t, e, o) { var s = this; s.log("Click on initial post .."), boundAsync.singleLeftClick(e, o).then(t => { console.log("Left Click"), s.runDelay(8e3, () => { s.instagramLoopOverPostsClick() }) }) }, alObject.prototype.instagramLoopOverPostsClick = function (e) { var o = this; e = e || 1, o.log("Like post; " + e + " of " + o._maxLikes); let t = jQuery("body").find("span._aamw span:has(svg)").eq(0); console.log("likeBtn:"), console.log(t); var s = jQuery("div._aaqg button._abl-"); console.log("nextBtn:"), console.log(s), 0 == t.length && (o.log(' - Could not find the "Like" button :('), 0 < s.length ? o.instagramClickNextButton(s, e) : o.restartProcess()); var l = t.offset(), n = parseInt(l.top - jQuery(window).scrollTop()), i = parseInt(l.left - jQuery(window).scrollLeft()); console.log("likeBtn = clickX: " + i + " ; clickY: " + n); let a = t.find("svg").eq(0); var r, c = a.attr("aria-label"); console.log("Like Text: " + c), "Like" === c ? (l = 1e3 * (r = o.getRandomInt(o._delayPerLikeMin, o._delayPerLikeMax)), o.log(" - not liked yet; delay before clicking like = " + r + " sec"), o.runDelay(l, () => { o.log(" - initiating clicking Like button .."), boundAsync.singleLeftClick(i + 10, n + 10).then(t => { o.log(" - clicked Like button .. wait to confirm .."), o.runDelay(4e3, () => { c = jQuery("body").find("span._aamw svg").eq(0).attr("aria-label"), console.log("Like Text: " + c), "Like" !== c ? (o.log(" - Successfully liked!"), o.instagramClickNextButton(s, e)) : (o.log(" - POST NOT LIKED! BLOCKED??"), o.log("*** STOPPING ***"), o.restartProcess()) }) }, t => { o.log(" - Error liking! Reason = " + t), o.instagramClickNextButton(s, e) }) })) : (o.log(" - already liked this post!"), o.instagramClickNextButton(s, e - 1)) }, alObject.prototype.instagramClickNextButton = function (t, e) { var o, s, l = this; e < l._maxLikes ? (l.log(" - Waiting before clicking on next button .."), t = t.offset(), console.log(t), o = parseInt(t.top - jQuery(window).scrollTop()), s = parseInt(t.left - jQuery(window).scrollLeft()), console.log("nextBtn = nextX: " + s + " ; nextY: " + o), l.runDelay(3e3, () => { boundAsync.singleLeftClick(s + 10, o + 10).then(t => { l.log(" - Successfully went to the next post! Wait 5 sec .."), l.runDelay(5e3, () => { var t = e + 1; l.instagramLoopOverPostsClick(t) }) }, t => { l.log(" - Error going to the next post! Reason = " + t) }) })) : (l.log(" - Reached end of list of posts, restarting process .."), l.runDelay(3e3, () => { l.restartProcess() })) }, alObject.prototype.restartProcess = function () { var o = this; if (console.log("*** restartProcess ***"), boundAsync) { let t; t = o._delayRestart || 15; var s = 6e4 * t; let e = new Date; var l = new Date(e.getTime() + s); o.log(e.toLocaleString() + ": RESTARTING in (min): " + t), o.log(" - Reloading at: " + l.toLocaleString()), o.runDelay(s, () => { boundAsync.restartProcess().then(t => { console.log("reloading ..") }) }) } }, alObject.prototype.runDelay = function (t, e) { setTimeout(e, t) }, alObject.prototype.log = function (t) { console.log(t), boundAsync && boundAsync.logMessage(t).then(t => { }, t => { console.error(t) }) }, alObject.prototype.getRandomInt = function (t, e) { return Math.floor(Math.random() * (e - t + 1)) + t }; \ No newline at end of file diff --git a/AutoLikerCefSharpWpf/Helper/AutoLikerSettingsManager.cs b/AutoLikerCefSharpWpf/Helper/AutoLikerSettingsManager.cs index 8c005c7..cdb4bbe 100644 --- a/AutoLikerCefSharpWpf/Helper/AutoLikerSettingsManager.cs +++ b/AutoLikerCefSharpWpf/Helper/AutoLikerSettingsManager.cs @@ -15,7 +15,17 @@ namespace AutoLikerCefSharpWpf.Helper 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.txtLocationTag.Text = Properties.Settings.Default.Instagram_Locations; main.txtDelayRestartMin.Text = Properties.Settings.Default.DelayRestartMin.ToString(); main.txtDelayRestartMax.Text = Properties.Settings.Default.DelayRestartMax.ToString(); main.txtMaxLikesMin.Text = Properties.Settings.Default.LikesMin.ToString(); @@ -25,19 +35,31 @@ namespace AutoLikerCefSharpWpf.Helper this.ToggleSettingsSaveButton(false); // assign handlers - main.txtHashTag.TextChanged += Al_Settings_TextChanged; - main.txtDelayRestartMin.TextChanged += Al_Settings_TextChanged; - main.txtDelayRestartMax.TextChanged += Al_Settings_TextChanged; - main.txtMaxLikesMin.TextChanged += Al_Settings_TextChanged; - main.txtMaxLikesMax.TextChanged += Al_Settings_TextChanged; - main.txtDelayMin.TextChanged += Al_Settings_TextChanged; - main.txtDelayMax.TextChanged += Al_Settings_TextChanged; + main.rdTypeHashTag.Checked += RadioButtonChanged; + main.rdTypeHashTag.Unchecked += RadioButtonChanged; + main.rdTypeLocationTag.Checked += RadioButtonChanged; + main.rdTypeLocationTag.Unchecked += RadioButtonChanged; + main.txtHashTag.TextChanged += TextFieldChanged; + main.txtLocationTag.TextChanged += TextFieldChanged; + 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; - Debug.WriteLine("Setting changed: " + tb.Name + " = " + tb.Text); + Debug.WriteLine($"Setting changed: {tb.Name} = {tb.Text}"); this.ToggleSettingsSaveButton(true); } @@ -62,7 +84,15 @@ namespace AutoLikerCefSharpWpf.Helper int.TryParse(main.txtDelayMin.Text, out int delayMin); 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_Locations = main.txtLocationTag.Text; Properties.Settings.Default.DelayRestartMin = delayRestartMin; Properties.Settings.Default.DelayRestartMax = delayRestartMax; Properties.Settings.Default.LikesMin = likesMin; diff --git a/AutoLikerCefSharpWpf/MainWindow.xaml b/AutoLikerCefSharpWpf/MainWindow.xaml index 9c9cf58..f6f5cd5 100644 --- a/AutoLikerCefSharpWpf/MainWindow.xaml +++ b/AutoLikerCefSharpWpf/MainWindow.xaml @@ -5,7 +5,7 @@ TextElement.Foreground="{DynamicResource MaterialDesignBody}" Background="{DynamicResource MaterialDesignPaper}" TextElement.FontWeight="Medium" - TextElement.FontSize="14" + TextElement.FontSize="12" FontFamily="{materialDesign:MaterialDesignFont}" xmlns:wpf="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf" xmlns:cef="clr-namespace:CefSharp;assembly=CefSharp.Core" @@ -39,8 +39,8 @@