-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
272 lines (243 loc) · 10.4 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
async function like(tabId) {
const script = () => {
const elements = document.getElementsByClassName("flex-wrap justify-center artdeco-button__text align-items-center");
for (let i = 0; i < elements.length; i++) { elements[i].click(); }
}
return await executeScriptInTab(tabId, script);
}
async function writeComments(tabId) {
const script = () => {
const textArray = [
"Great insights! Thanks for sharing your expertise.",
"I'm inspired by your dedication and passion for your work.",
"Your accomplishments are truly impressive. Keep up the fantastic work!",
"This is valuable information. Thanks for keeping us informed.",
"Congratulations on your success! You deserve all the recognition.",
"I appreciate the positive impact you're making in your field.",
"Your work ethic and determination are commendable.",
"Thanks for being an inspiration to others in the industry.",
"Your thought leadership is making a difference. Keep it up!",
"Your expertise shines through in every post you make.",
"I'm grateful for the valuable content you consistently share.",
"You're a true leader, and your advice is always on point.",
"It's clear that you put a lot of effort into creating valuable content.",
"I've learned so much from following your posts. Thank you!",
"Your positivity is contagious. Keep spreading the good vibes!",
"Your dedication to continuous learning is admirable.",
"Thanks for sharing your experiences and lessons learned.",
"Your posts are always insightful and thought-provoking.",
"You have a unique perspective that adds value to every discussion.",
"You're making a significant impact, and I look forward to more of your contributions.",
"Fantastic!",
"Awesome!",
"Excellent!",
"Superb!",
"Terrific!",
"Outstanding!",
"Marvelous!",
"Impressive!",
"Wonderful!",
"Splendid!",
"Fabulous!",
"Brilliant!",
"Amazing!",
"Stellar!",
"Magnificent!",
"Incredible!",
"Phenomenal!",
"Super!",
"First-rate!",
"Nice post",
"Post, nice",
"Post that is nice",
"A post worth appreciating",
"Great post",
"Post of excellence",
"A nicely written post",
"Impressive post",
"Well done with the post",
"Post, nicely done",
"Post with a touch of brilliance",
"Fantastic post",
"Post that deserves applause",
"Kudos for the post",
"Post that shines",
"An amazing post",
"Remarkable post",
"Post with a wow factor",
"Outstanding post",
"Nice, thanks for sharing.",
"A delightful share!",
"Thanks for the nice share.",
"A nice share to remember."
]
const modifiedTextArray = textArray.map(text => {
// Add '\n\n' after '!' or '.'
const modifiedText = text.replace(/([!.])(\s*)/g, '$1\n\n');
// Modify the text with a 50% chance
const shouldModify = Math.random() < 0.5;
const modifiedRandomText = shouldModify ? modifiedText : text;
return modifiedRandomText;
});
const divs = document.querySelectorAll('div.comments-comment-texteditor');
divs.forEach(div => {
const inputField = div.querySelector('.ql-editor');
const randomIndex = Math.floor(Math.random() * textArray.length);
const randomText = modifiedTextArray[randomIndex];
inputField.innerHTML = randomText;
});
}
return await executeScriptInTab(tabId, script);
}
async function publishComments(tabId) {
const script = () => {
const buttons = document.querySelectorAll('button.comments-comment-box__submit-button');
const clickButton = (button) => {
button.click();
};
buttons.forEach((button, index) => {
setTimeout(() => {
clickButton(button);
}, index * 5000); // Delay each click by 5 seconds (5000 milliseconds)
});
}
return await executeScriptInTab(tabId, script);
}
async function loadMoreComments(tabId) {
const script = () => {
const loadMoreButtons = document.querySelectorAll('button.comments-comments-list__load-more-comments-button');
loadMoreButtons.forEach(button => button.click());
}
return await executeScriptInTab(tabId, script);
}
async function clickReply(tabId) {
const script = () => {
const replyButtons = document.querySelectorAll('button.comments-comment-social-bar__reply-action-button');
replyButtons.forEach(button => button.click());
}
return await executeScriptInTab(tabId, script);
}
async function clickComments(tabId) {
const script = () => {
const commentButtons = document.querySelectorAll('button.comment-button');
commentButtons.forEach(button => button.click());
}
return await executeScriptInTab(tabId, script);
}
async function scrollPage(tabId) {
const script = () => {
// Set the number of times to scroll and the interval in milliseconds
const scrollCount = 10;
const interval = 15000;
let scrollIndex = 0;
// Function to scroll the page
function scrollToNext() {
if (scrollIndex < scrollCount) {
window.scrollTo(0, document.body.scrollHeight);
scrollIndex++;
} else {
clearInterval(scrollInterval);
}
}
// Start the scrolling interval
const scrollInterval = setInterval(scrollToNext, interval);
}
return await executeScriptInTab(tabId, script);
}
async function featureBody(tabId) {
const script = () => {
//script goes here
}
return await executeScriptInTab(tabId, script);
}
async function workflowLW(tabId) {
await like(tabId);
await writeComments(tabId);
}
async function workflowCW(tabId) {
await clickComments(tabId);
await writeComments(tabId);
}
async function workflowPL(tabId) {
await publishComments(tabId);
await like(tabId);
}
async function getCurrentTabId() {
try {
const queryOptions = { active: true, currentWindow: true };
const [tab] = await chrome.tabs.query(queryOptions);
if (tab) {
return tab.id;
} else {
console.error("No active tab found.");
return null;
}
} catch (error) {
console.error("Error getting current tab:", error);
return null;
}
}
async function executeScriptInTab(tabId, script) {
try {
const [result] = await chrome.scripting.executeScript({
target: { tabId: tabId },
func: script,
});
return result;
} catch (error) {
console.error("Error executing script:", error);
return null;
}
}
async function handleButtonClick(actionFunction, button, successMessage, errorMessage) {
const tabId = await getCurrentTabId();
if (tabId) {
console.log(`${actionFunction.name}()`);
await actionFunction(tabId);
button.innerHTML = successMessage;
} else {
button.innerHTML = errorMessage;
button.style = "background-color:red;";
console.error("Error getting tabId.");
}
}
var likeButton = document.getElementById("likebtn");
var writeCommentsButton = document.getElementById("write-commentsbtn");
var publishCommentsButton = document.getElementById("publish-commentbtn");
var loadMoreCommentsButton = document.getElementById("loadmore-commentsbtn");
var clickReplyButton = document.getElementById("click-replybtn");
var clickCommentsButton = document.getElementById("click-commentsbtn");
var scrollPageButton = document.getElementById("scroll-pagebtn");
var workflowLWButton = document.getElementById("workflow-lwbtn");
var workflowCWButton = document.getElementById("workflow-cwbtn");
var workflowPLButton = document.getElementById("workflow-plbtn");
likeButton.addEventListener("click", async function () {
await handleButtonClick(like, likeButton, "Liked! 😎", "Something went wrong!");
}, false);
writeCommentsButton.addEventListener("click", async function () {
await handleButtonClick(writeComments, writeCommentsButton, "Comments Written! 😎", "Something went wrong!");
}, false);
publishCommentsButton.addEventListener("click", async function () {
await handleButtonClick(publishComments, publishCommentsButton, "Comments Publishing! 😎", "Something went wrong!");
}, false);
loadMoreCommentsButton.addEventListener("click", async function () {
await handleButtonClick(loadMoreComments, loadMoreCommentsButton, "Comments loaded! 😎", "Something went wrong!");
}, false);
clickReplyButton.addEventListener("click", async function () {
await handleButtonClick(clickReply, clickReplyButton, "Replies clicked! 😎", "Something went wrong!");
}, false);
scrollePageButton.addEventListener("click", async function () {
await handleButtonClick(scrollePage, scrollePageButton, "Scroll Page clicked! 😎", "Something went wrong!");
}, false);
workflowLWButton.addEventListener("click", async function () {
await handleButtonClick(workflowLW, workflowLWButton, "Workflow LW clicked! 😎", "Something went wrong!");
}, false);
workflowCWButton.addEventListener("click", async function () {
await handleButtonClick(workflowCW, workflowCWButton, "Workflow CW clicked! 😎", "Something went wrong!");
}, false);
workflowPLButton.addEventListener("click", async function () {
await handleButtonClick(workflowPL, workflowPLButton, "Workflow PL clicked! 😎", "Something went wrong!");
}, false);
workflowPLButton.addEventListener("click", async function () {
await handleButtonClick(workflowPL, workflowPLButton, "Workflow PL clicked! 😎", "Something went wrong!");
}, false);