Fix for DOM changes + cache folder

This commit is contained in:
Jack 2024-03-30 12:31:26 -04:00
parent bd800ad504
commit 3789ef20c7
6 changed files with 58 additions and 35 deletions

View File

@ -17,7 +17,7 @@ namespace AutoLikerCefSharpWpf
var settings = new CefSettings() var settings = new CefSettings()
{ {
//By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data //By default CefSharp will use an in-memory cache, you need to specify a Cache Folder to persist data
CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "CefSharp\\Cache") CachePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "AutoLiker2\\Cache")
}; };
//Example of setting a command line argument //Example of setting a command line argument

View File

@ -55,8 +55,10 @@ alObject.prototype.instagramStartClickProcess = function(retry=0) {
let most_recent = jQuery('h2').eq(1); let most_recent = jQuery('h2').eq(1);
let jump_to_section = null; let jump_to_section = null;
if (most_recent.length > 0) { if (most_recent.length > 0) {
thisObj.log(' - Using "Most Recent" list');
jump_to_section = most_recent; jump_to_section = most_recent;
} else if (most_recent.length == 0 && top_posts.length > 0) { } else if (most_recent.length == 0 && top_posts.length > 0) {
thisObj.log(' - Using "Top Posts" list');
jump_to_section = top_posts; jump_to_section = top_posts;
} }
@ -74,17 +76,27 @@ alObject.prototype.instagramStartClickProcess = function(retry=0) {
} }
} else { } else {
let mr_div = jump_to_section.next(); let divJumpTo = jump_to_section.parent(); // get parent <div> of <h2> 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();
});
} else {
divJumpTo = divJumpTo.next(); // go to the next sibling (posts <div>)
thisObj.log('Scroll to list ..'); thisObj.log('Scroll to list ..');
jQuery('html, body').animate({ scrollTop: mr_div.offset().top }, 500); jQuery('html, body').animate({ scrollTop: divJumpTo.offset().top }, 500);
let parentX = mr_div.offset().left; let parentX = divJumpTo.offset().left;
let parentY = mr_div.offset().top; let parentY = divJumpTo.offset().top;
thisObj._scrollOffset = mr_div.offset(); thisObj._scrollOffset = divJumpTo.offset();
console.log('parentX: ' + parentX + ' ; parentY: ' + parentY); console.log('parentX: ' + parentX + ' ; parentY: ' + parentY);
thisObj.runDelay(2000, () => { thisObj.runDelay(2000, () => {
let child01 = mr_div.children('div').eq(0); let child01 = divJumpTo.children('div').eq(0);
let postLinks = child01.find('a'); let postLinks = child01.find('a');
postLinks.each( function(i) { postLinks.each(function (i) {
thisObj._postItems.push(jQuery(this).attr('href')); thisObj._postItems.push(jQuery(this).attr('href'));
}); });
console.log('items:'); console.log('items:');
@ -107,6 +119,7 @@ alObject.prototype.instagramStartClickProcess = function(retry=0) {
} }
}); });
} }
}
}); });
} }

File diff suppressed because one or more lines are too long

View File

@ -161,6 +161,7 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<None Include="app.manifest" /> <None Include="app.manifest" />
<None Include="README.md" />
<None Include="packages.config" /> <None Include="packages.config" />
<None Include="Properties\Settings.settings"> <None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator> <Generator>SettingsSingleFileGenerator</Generator>

View File

@ -2,7 +2,6 @@
using CefSharp; using CefSharp;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Input; using System.Windows.Input;
@ -21,7 +20,7 @@ namespace AutoLikerCefSharpWpf
InitializeComponent(); InitializeComponent();
// version // version
this.AutoLikerVersion = "v2.0.6-20240205"; this.AutoLikerVersion = "v2.0.7-20240330";
this.DataContext = this; this.DataContext = this;
// manage settings in UI // manage settings in UI
this._alsm = new AutoLikerSettingsManager(this); this._alsm = new AutoLikerSettingsManager(this);
@ -84,7 +83,11 @@ namespace AutoLikerCefSharpWpf
args.Frame.ExecuteJavaScriptAsync(jq); args.Frame.ExecuteJavaScriptAsync(jq);
// Inject AutoLiker class // Inject AutoLiker class
#if DEBUG
string aljs = JavaScriptProcessor.ReturnJavaScriptFromFile("autotag_injection.js");
#else
string aljs = JavaScriptProcessor.ReturnJavaScriptFromFile("autotag_injection_min.js"); string aljs = JavaScriptProcessor.ReturnJavaScriptFromFile("autotag_injection_min.js");
#endif
args.Frame.ExecuteJavaScriptAsync(aljs); args.Frame.ExecuteJavaScriptAsync(aljs);
this.Dispatcher.Invoke(() => this.Dispatcher.Invoke(() =>

View File

@ -0,0 +1,6 @@
# Auto Liker CefSharp WPF
Automate liking of Instagram posts.
## Release Notes
* v2.0.7-20240330
* #3 Fix H2 scrolling issue