element
+ if (divJumpTo.siblings().length < 1) {
+ divJumpTo = jump_to_section.parent().parent();
+ }
+ if (divJumpTo.siblings().length < 1) {
+ thisObj.log('ERROR: couldn\'t find list of posts!');
+ thisObj.runDelay(1000, () => {
+ thisObj.restartProcess();
});
- console.log('items:');
- console.log(thisObj._postItems);
- thisObj.log('Found posts: ' + thisObj._postItems.length);
- // get first post
- let element01 = jQuery('a[href="' + thisObj._postItems[0] + '"]');
- console.log(element01);
- let element02 = element01.find('img').eq(0);
- console.log(element02);
- console.log(element02.attr('src'));
- if (element02) {
- console.log('imgX: ' + element02.offset().left + ' ; imgY: ' + element02.offset().top);
- //let clickX = parseInt(parentX - element02.offset().left) + 1;
- let clickX = parseInt(element02.offset().left) + 30;
- let clickY = parseInt(parentY - element02.offset().top) + 60;
- console.log('clickX: ' + clickX + ' ; clickY: ' + clickY);
- thisObj.log('Will like this many posts: ' + thisObj._maxLikes);
- thisObj.instagramClickPost(element02, clickX, clickY);
- }
- });
+ } else {
+ divJumpTo = divJumpTo.next(); // go to the next sibling (posts
)
+ thisObj.log('Scroll to list ..');
+ jQuery('html, body').animate({ scrollTop: divJumpTo.offset().top }, 500);
+ let parentX = divJumpTo.offset().left;
+ let parentY = divJumpTo.offset().top;
+ thisObj._scrollOffset = divJumpTo.offset();
+ console.log('parentX: ' + parentX + ' ; parentY: ' + parentY);
+ thisObj.runDelay(2000, () => {
+ let child01 = divJumpTo.children('div').eq(0);
+ let postLinks = child01.find('a');
+ postLinks.each(function (i) {
+ thisObj._postItems.push(jQuery(this).attr('href'));
+ });
+ console.log('items:');
+ console.log(thisObj._postItems);
+ thisObj.log('Found posts: ' + thisObj._postItems.length);
+ // get first post
+ let element01 = jQuery('a[href="' + thisObj._postItems[0] + '"]');
+ console.log(element01);
+ let element02 = element01.find('img').eq(0);
+ console.log(element02);
+ console.log(element02.attr('src'));
+ if (element02) {
+ console.log('imgX: ' + element02.offset().left + ' ; imgY: ' + element02.offset().top);
+ //let clickX = parseInt(parentX - element02.offset().left) + 1;
+ let clickX = parseInt(element02.offset().left) + 30;
+ let clickY = parseInt(parentY - element02.offset().top) + 60;
+ console.log('clickX: ' + clickX + ' ; clickY: ' + clickY);
+ thisObj.log('Will like this many posts: ' + thisObj._maxLikes);
+ thisObj.instagramClickPost(element02, clickX, clickY);
+ }
+ });
+ }
}
});
}
diff --git a/AutoLikerCefSharpWpf/Assets/autotag_injection_min.js b/AutoLikerCefSharpWpf/Assets/autotag_injection_min.js
index a635080..b772b96 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, l, s, n, i) { if (this._tag = t, this._likesMin = e, this._likesMax = o, this._delayPerLikeMin = l, this._delayPerLikeMax = s, this._delayRestartMin = n, this._delayRestartMax = i, console.log("tag:" + t + " | likesMin:" + e + " | likesMax:" + o + " | delayMin: " + l + " | delayMax: " + s + " | 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 (l = 0) { var r = this; r._postItems = [], console.log("*** instagramStartClickProcess ***"), window.scrollTo(0, 0), r.log(" - wait 20s for page to load..."), r.runDelay(2e4, () => { 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!"), l < 2 ? (r.log(" - Retry #" + (l + 1) + ": retrying after 30 seconds (to give IG time to load)."), r.runDelay(3e4, () => { r.instagramStartClickProcess(l++) })) : 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 l = o.find("img").eq(0); var s, n; console.log(l), console.log(l.attr("src")), l && (console.log("imgX: " + l.offset().left + " ; imgY: " + l.offset().top), s = parseInt(l.offset().left) + 30, n = parseInt(a - l.offset().top) + 60, console.log("clickX: " + s + " ; clickY: " + n), r.log("Will like this many posts: " + r._maxLikes), r.instagramClickPost(l, s, n)) }) } }) }, alObject.prototype.instagramClickPost = function (t, e, o) { var l = this; l.log("Click on initial post .."), boundAsync.singleLeftClick(e, o).then(t => { console.log("Left Click"), l.runDelay(8e3, () => { l.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('svg[aria-label="Like"], svg[aria-label="Unlike"]').eq(0); console.log("likeBtn:"), console.log(t); let l = jQuery("body").find("svg[aria-label='Next'], svg[aria-label='Navigate to previous item']").eq(0); console.log("nextBtn:"), console.log(l), 0 < t.length ? (console.log(' - Found "like" button object'), t = t.parent(), l = 0 < l.length ? l.parent() : null) : (o.log(' - Could not find the "Like" button'), 0 < l.length ? o.instagramClickNextButton(l.parent(), e) : (o.log(' - Could not find the "Next" button'), o.restartProcess())); var s = t.offset(), n = parseInt(s.top - jQuery(window).scrollTop()), i = parseInt(s.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 ? (s = 1e3 * (r = o.getRandomInt(o._delayPerLikeMin, o._delayPerLikeMax)), o.log(" - not liked yet; delay before clicking like = " + r + " sec"), o.runDelay(s, () => { 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(l, e)) : (o.log(" - POST NOT LIKED! BLOCKED??"), o.log("*** STOPPING ***"), o.restartProcess()) }) }, t => { o.log(" - Error liking! Reason = " + t), o.instagramClickNextButton(l, e) }) })) : (o.log(" - already liked this post!"), o.instagramClickNextButton(l, e - 1)) }, alObject.prototype.instagramClickNextButton = function (t, e) { var o, l, s, n = this; e < n._maxLikes && t ? (n.log(" - Waiting before clicking on next button .."), o = t.offset(), console.log(o), l = parseInt(o.top - jQuery(window).scrollTop()), s = parseInt(o.left - jQuery(window).scrollLeft()), console.log("nextBtn = nextX: " + s + " ; nextY: " + l), n.runDelay(3e3, () => { boundAsync.singleLeftClick(s + 10, l + 10).then(t => { n.log(" - Successfully went to the next post! Wait 5 sec .."), n.runDelay(5e3, () => { var t = e + 1; n.instagramLoopOverPostsClick(t) }) }, t => { n.log(" - Error going to the next post! Reason = " + t) }) })) : (t ? n.log(" - Reached end of list of posts, restarting process ..") : n.log(" - Couldn't find Next button, restarting process .."), n.runDelay(3e3, () => { n.restartProcess() })) }, alObject.prototype.restartProcess = function () { var o = this; if (console.log("*** restartProcess ***"), boundAsync) { let t; t = o._delayRestart || 15; var l = 6e4 * t; let e = new Date; var s = new Date(e.getTime() + l); o.log(e.toLocaleString() + ": RESTARTING in (min): " + t), o.log(" - Reloading at: " + s.toLocaleString()), o.runDelay(l, () => { 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, l, s, n, i) { if (this._tag = t, this._likesMin = e, this._likesMax = o, this._delayPerLikeMin = l, this._delayPerLikeMax = s, this._delayRestartMin = n, this._delayRestartMax = i, console.log("tag:" + t + " | likesMin:" + e + " | likesMax:" + o + " | delayMin: " + l + " | delayMax: " + s + " | 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 (l = 0) { var r = this; r._postItems = [], console.log("*** instagramStartClickProcess ***"), window.scrollTo(0, 0), r.log(" - wait 20s for page to load..."), r.runDelay(2e4, () => { r.log((new Date).toLocaleString() + ": Starting click process .."); var a, t = jQuery("h2").eq(0), e = jQuery("h2").eq(1); let o = null; if (0 < e.length ? (r.log(' - Using "Most Recent" list'), o = e) : 0 == e.length && 0 < t.length && (r.log(' - Using "Top Posts" list'), o = t), null == o || 0 == o) r.log("ERROR: couldn't find most recent or top posts sections!"), l < 2 ? (r.log(" - Retry #" + (l + 1) + ": retrying after 30 seconds (to give IG time to load)."), r.runDelay(3e4, () => { r.instagramStartClickProcess(l++) })) : r.runDelay(1e3, () => { r.restartProcess() }); else { let i = o.parent(); i.siblings().length < 1 && (i = o.parent().parent()), i.siblings().length < 1 ? (r.log("ERROR: couldn't find list of posts!"), r.runDelay(1e3, () => { r.restartProcess() })) : (i = i.next(), r.log("Scroll to list .."), jQuery("html, body").animate({ scrollTop: i.offset().top }, 500), 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 l = o.find("img").eq(0); var s, n; console.log(l), console.log(l.attr("src")), l && (console.log("imgX: " + l.offset().left + " ; imgY: " + l.offset().top), s = parseInt(l.offset().left) + 30, n = parseInt(a - l.offset().top) + 60, console.log("clickX: " + s + " ; clickY: " + n), r.log("Will like this many posts: " + r._maxLikes), r.instagramClickPost(l, s, n)) })) } }) }, alObject.prototype.instagramClickPost = function (t, e, o) { var l = this; l.log("Click on initial post .."), boundAsync.singleLeftClick(e, o).then(t => { console.log("Left Click"), l.runDelay(8e3, () => { l.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('svg[aria-label="Like"], svg[aria-label="Unlike"]').eq(0); console.log("likeBtn:"), console.log(t); let l = jQuery("body").find("svg[aria-label='Next'], svg[aria-label='Navigate to previous item']").eq(0); console.log("nextBtn:"), console.log(l), 0 < t.length ? (console.log(' - Found "like" button object'), t = t.parent(), l = 0 < l.length ? l.parent() : null) : (o.log(' - Could not find the "Like" button'), 0 < l.length ? o.instagramClickNextButton(l.parent(), e) : (o.log(' - Could not find the "Next" button'), o.restartProcess())); var s = t.offset(), n = parseInt(s.top - jQuery(window).scrollTop()), i = parseInt(s.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 ? (s = 1e3 * (r = o.getRandomInt(o._delayPerLikeMin, o._delayPerLikeMax)), o.log(" - not liked yet; delay before clicking like = " + r + " sec"), o.runDelay(s, () => { 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(l, e)) : (o.log(" - POST NOT LIKED! BLOCKED??"), o.log("*** STOPPING ***"), o.restartProcess()) }) }, t => { o.log(" - Error liking! Reason = " + t), o.instagramClickNextButton(l, e) }) })) : (o.log(" - already liked this post!"), o.instagramClickNextButton(l, e - 1)) }, alObject.prototype.instagramClickNextButton = function (t, e) { var o, l, s, n = this; e < n._maxLikes && t ? (n.log(" - Waiting before clicking on next button .."), o = t.offset(), console.log(o), l = parseInt(o.top - jQuery(window).scrollTop()), s = parseInt(o.left - jQuery(window).scrollLeft()), console.log("nextBtn = nextX: " + s + " ; nextY: " + l), n.runDelay(3e3, () => { boundAsync.singleLeftClick(s + 10, l + 10).then(t => { n.log(" - Successfully went to the next post! Wait 5 sec .."), n.runDelay(5e3, () => { var t = e + 1; n.instagramLoopOverPostsClick(t) }) }, t => { n.log(" - Error going to the next post! Reason = " + t) }) })) : (t ? n.log(" - Reached end of list of posts, restarting process ..") : n.log(" - Couldn't find Next button, restarting process .."), n.runDelay(3e3, () => { n.restartProcess() })) }, alObject.prototype.restartProcess = function () { var o = this; if (console.log("*** restartProcess ***"), boundAsync) { let t; t = o._delayRestart || 15; var l = 6e4 * t; let e = new Date; var s = new Date(e.getTime() + l); o.log(e.toLocaleString() + ": RESTARTING in (min): " + t), o.log(" - Reloading at: " + s.toLocaleString()), o.runDelay(l, () => { 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/AutoLikerCefSharpWpf.csproj b/AutoLikerCefSharpWpf/AutoLikerCefSharpWpf.csproj
index eacbaaa..4391835 100644
--- a/AutoLikerCefSharpWpf/AutoLikerCefSharpWpf.csproj
+++ b/AutoLikerCefSharpWpf/AutoLikerCefSharpWpf.csproj
@@ -161,6 +161,7 @@
Resources.Designer.cs
+
SettingsSingleFileGenerator
diff --git a/AutoLikerCefSharpWpf/MainWindow.xaml.cs b/AutoLikerCefSharpWpf/MainWindow.xaml.cs
index 32ad0e9..24f7170 100644
--- a/AutoLikerCefSharpWpf/MainWindow.xaml.cs
+++ b/AutoLikerCefSharpWpf/MainWindow.xaml.cs
@@ -2,7 +2,6 @@
using CefSharp;
using System;
using System.Diagnostics;
-using System.Linq;
using System.Windows;
using System.Windows.Input;
@@ -21,7 +20,7 @@ namespace AutoLikerCefSharpWpf
InitializeComponent();
// version
- this.AutoLikerVersion = "v2.0.6-20240205";
+ this.AutoLikerVersion = "v2.0.7-20240330";
this.DataContext = this;
// manage settings in UI
this._alsm = new AutoLikerSettingsManager(this);
@@ -84,7 +83,11 @@ namespace AutoLikerCefSharpWpf
args.Frame.ExecuteJavaScriptAsync(jq);
// Inject AutoLiker class
+#if DEBUG
+ string aljs = JavaScriptProcessor.ReturnJavaScriptFromFile("autotag_injection.js");
+#else
string aljs = JavaScriptProcessor.ReturnJavaScriptFromFile("autotag_injection_min.js");
+#endif
args.Frame.ExecuteJavaScriptAsync(aljs);
this.Dispatcher.Invoke(() =>
diff --git a/AutoLikerCefSharpWpf/README.md b/AutoLikerCefSharpWpf/README.md
new file mode 100644
index 0000000..4074c57
--- /dev/null
+++ b/AutoLikerCefSharpWpf/README.md
@@ -0,0 +1,6 @@
+# Auto Liker CefSharp WPF
+Automate liking of Instagram posts.
+
+## Release Notes
+* v2.0.7-20240330
+ * #3 Fix H2 scrolling issue
\ No newline at end of file