coffeeinabit 0.0.14 → 0.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/linkedin_automation.js +28 -8
- package/package.json +1 -1
- package/public/dashboard.html +537 -510
- package/public/styles.css +53 -1
- package/server.js +3 -1
- package/tools/comment_post.js +3 -1
- package/tools/context_paths.js +24 -0
- package/tools/cookie_manager.js +4 -3
- package/tools/get_daily_linkedin_connections.js +3 -1
- package/tools/get_linkedin_search_results.js +4 -2
- package/tools/get_messages.js +3 -1
- package/tools/get_new_messages.js +3 -2
- package/tools/get_profile.js +5 -3
- package/tools/like_post.js +3 -1
- package/tools/navigation.js +32 -0
- package/tools/send_connection_request.js +3 -1
- package/tools/send_messages.js +2 -1
package/linkedin_automation.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { firefox } from 'playwright';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import fs from 'fs';
|
|
4
|
+
import { getContextDirectory } from './tools/context_paths.js';
|
|
4
5
|
import { fileURLToPath } from 'url';
|
|
5
6
|
import { humanLikeType, readLinkedInCredentials } from './tools/human_typing.js';
|
|
6
7
|
import { executeGetProfile } from './tools/get_profile.js';
|
|
@@ -13,6 +14,7 @@ import { executeLinkedInSearch } from './tools/get_linkedin_search_results.js';
|
|
|
13
14
|
import { executeGetDailyLinkedInConnections } from './tools/get_daily_linkedin_connections.js';
|
|
14
15
|
import { executeGetNewMessages } from './tools/get_new_messages.js';
|
|
15
16
|
import { executeGetLinkedInUpdates } from './tools/get_linkedin_updates.js';
|
|
17
|
+
import { safeGoto } from './tools/navigation.js';
|
|
16
18
|
|
|
17
19
|
const __filename = fileURLToPath(import.meta.url);
|
|
18
20
|
const __dirname = path.dirname(__filename);
|
|
@@ -34,7 +36,7 @@ export class LinkedInAutomation {
|
|
|
34
36
|
this.currentAction = null;
|
|
35
37
|
this.userEmail = null;
|
|
36
38
|
this.isActionPollingActive = false;
|
|
37
|
-
this.linkedInSessionDir =
|
|
39
|
+
this.linkedInSessionDir = getContextDirectory();
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
getLinkedInSessionPath() {
|
|
@@ -256,7 +258,7 @@ export class LinkedInAutomation {
|
|
|
256
258
|
}
|
|
257
259
|
|
|
258
260
|
console.log('[LinkedInAutomation] Navigating to LinkedIn login page...');
|
|
259
|
-
await this.page
|
|
261
|
+
await safeGoto(this.page, 'https://www.linkedin.com/login', {
|
|
260
262
|
waitUntil: 'domcontentloaded',
|
|
261
263
|
timeout: 60000
|
|
262
264
|
});
|
|
@@ -739,7 +741,7 @@ export class LinkedInAutomation {
|
|
|
739
741
|
const { result, status } = await response.json();
|
|
740
742
|
|
|
741
743
|
if (status === 'completed' && result) {
|
|
742
|
-
console.log(`[LinkedInAutomation] Task ${taskId} completed, processing results
|
|
744
|
+
console.log(`[LinkedInAutomation] Task ${taskId} completed, processing results: `, JSON.stringify(result, null, 2));
|
|
743
745
|
this.status = 'processing_followup_actions';
|
|
744
746
|
this.emitStatus();
|
|
745
747
|
await this.processTaskResults(result, action);
|
|
@@ -749,7 +751,7 @@ export class LinkedInAutomation {
|
|
|
749
751
|
} else if (status === 'processing') {
|
|
750
752
|
console.log(`[LinkedInAutomation] Task ${taskId} still processing...`);
|
|
751
753
|
} else {
|
|
752
|
-
console.log(`[LinkedInAutomation] Task ${taskId} status: ${status}`);
|
|
754
|
+
console.log(`[LinkedInAutomation] Task ${taskId} status: ${status}: ${JSON.stringify(result)}`);
|
|
753
755
|
}
|
|
754
756
|
} else if (response.status === 404) {
|
|
755
757
|
console.log(`[LinkedInAutomation] Task ${taskId} not found yet, continuing to poll...`);
|
|
@@ -776,16 +778,34 @@ export class LinkedInAutomation {
|
|
|
776
778
|
|
|
777
779
|
async processTaskResults(taskResult, oldAction) {
|
|
778
780
|
try {
|
|
781
|
+
console.log('[LinkedInAutomation] Processing task results:', JSON.stringify(taskResult, null, 2));
|
|
779
782
|
const { new_actions, status, scheduled_actions_count } = taskResult;
|
|
780
783
|
|
|
781
784
|
console.log(`[LinkedInAutomation] Processing task results - Status: ${status}, scheduled_actions_count: ${scheduled_actions_count || 0}, new_actions: ${new_actions ? new_actions.length : 0}`);
|
|
782
785
|
|
|
783
786
|
if (new_actions && new_actions.length > 0) {
|
|
784
787
|
console.log(`[LinkedInAutomation] Received ${new_actions.length} new actions from backend`);
|
|
788
|
+
const now = Date.now();
|
|
789
|
+
const readyActions = [];
|
|
785
790
|
for (const action of new_actions) {
|
|
786
|
-
|
|
787
|
-
|
|
791
|
+
const executionTime = action.execution_datetime_fmt || action.execution_datetime;
|
|
792
|
+
if (executionTime) {
|
|
793
|
+
const parsedExecution = new Date(executionTime);
|
|
794
|
+
if (!Number.isNaN(parsedExecution.getTime()) && parsedExecution.getTime() > now) {
|
|
795
|
+
console.log(`[LinkedInAutomation] Action ${action.action_id} scheduled for future at ${executionTime}, skipping for now`);
|
|
796
|
+
continue;
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
readyActions.push(action);
|
|
800
|
+
}
|
|
801
|
+
if (readyActions.length > 0) {
|
|
802
|
+
for (const action of readyActions) {
|
|
803
|
+
console.log(`[LinkedInAutomation] Queueing action: ${action.action} (${action.action_id})`);
|
|
804
|
+
await this.executeAction(action);
|
|
805
|
+
}
|
|
806
|
+
return;
|
|
788
807
|
}
|
|
808
|
+
console.log('[LinkedInAutomation] All new actions are scheduled for future execution, skipping for now');
|
|
789
809
|
return;
|
|
790
810
|
}
|
|
791
811
|
|
|
@@ -879,7 +899,7 @@ export class LinkedInAutomation {
|
|
|
879
899
|
await this.enablePerformanceMode();
|
|
880
900
|
this.page = await this.context.newPage();
|
|
881
901
|
|
|
882
|
-
await this.page
|
|
902
|
+
await safeGoto(this.page, currentUrl, {
|
|
883
903
|
waitUntil: 'domcontentloaded',
|
|
884
904
|
timeout: 30000
|
|
885
905
|
});
|
|
@@ -902,7 +922,7 @@ export class LinkedInAutomation {
|
|
|
902
922
|
async checkAndVerifySession() {
|
|
903
923
|
try {
|
|
904
924
|
console.log('[LinkedInAutomation] Navigating to LinkedIn feed to verify persistent session...');
|
|
905
|
-
await this.page
|
|
925
|
+
await safeGoto(this.page, 'https://www.linkedin.com/feed/', {
|
|
906
926
|
waitUntil: 'domcontentloaded',
|
|
907
927
|
timeout: 30000
|
|
908
928
|
});
|