-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
152 lines (125 loc) · 4.9 KB
/
script.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
// Made by github.com/zebbern
// Define the target username and URL
const targetUsername = "@test";
const targetURL = "https://link.com";
// Function to input the URL into the search field
function inputURL(callback) {
const urlInput = document.querySelector("body > div.col-sm-5.col-xs-12.p-1.container.t-chearts-menu > div > form > div > input");
if (urlInput) {
urlInput.value = targetURL; // Input the target URL
const event = new Event("input"); // Trigger the input event
urlInput.dispatchEvent(event);
console.log(`URL "${targetURL}" inputted successfully!`);
setTimeout(callback, 1000); // Wait 1 second before moving to the next step
} else {
console.log("URL input field not found.");
}
}
// Function to click the search button
function clickSearchButton(callback) {
const searchButton = document.querySelector('form[action="c2VuZC9mb2xsb3dlcnNfdGlrdG9r"] button[type="submit"]');
if (searchButton) {
searchButton.click();
console.log("Search button clicked successfully!");
setTimeout(callback, 2000); // Wait 2 seconds for the page to load
} else {
console.log("Search button not found.");
}
}
// Function to click `.wbutton`
function clickWButton(callback) {
const wButton = document.querySelector('.wbutton');
if (wButton) {
wButton.click();
console.log(".wbutton clicked successfully!");
setTimeout(callback, 2000); // Wait 2 seconds for the page to load
} else {
console.log(".wbutton not found.");
}
}
// Function to search for the username and click the button
function searchAndClickButton() {
// Find the div containing the target username
const userDiv = Array.from(document.querySelectorAll('.font-weight-bold.d-inline-flex.kadi-rengi'))
.find(div => div.textContent.trim() === targetUsername);
if (userDiv) {
console.log(`Found the username: ${targetUsername}`);
// Navigate to the parent form
const form = userDiv.closest('form');
if (form) {
// Find the button inside the form
const button = form.querySelector('button.btn.btn-primary.rounded-0');
if (button) {
// Click the button
button.click();
console.log(`Button clicked for username: ${targetUsername}`);
} else {
console.log("Button not found in the form.");
}
} else {
console.log("Form not found for the username.");
}
// Update dropdowns globally
updateDropdownsInForm();
return true; // Username found
} else {
console.log(`Username ${targetUsername} not found on this page.`);
return false; // Username not found
}
}
// Function to update dropdowns globally
function updateDropdownsInForm() {
const selectDropdowns = document.querySelectorAll('select[name="select_lmt"].form-select.dark-select.text-dark.rounded-0.font-weight-bold.mb-1.mt-1.p-1');
// Loop through each dropdown and set its value to 100
selectDropdowns.forEach(dropdown => {
if (dropdown) {
dropdown.value = "100";
// Trigger the change event in case the page needs it to register the change
const event = new Event("change");
dropdown.dispatchEvent(event);
console.log("Dropdown value set to 100 successfully for one element!");
}
});
console.log(`Updated ${selectDropdowns.length} dropdown(s) to 100.`);
}
// Function to click the "Next" button
function clickNextButton(callback) {
const nextButton = document.querySelector('li.page-item form button[type="submit"].btn.btn-light.rounded-0.font-weight-bold');
if (nextButton) {
nextButton.click();
console.log("Next button clicked. Waiting for the next page to load...");
setTimeout(callback, 3000); // Wait 3 seconds for the next page to load
return true;
} else {
console.log("Next button not found. Reached the end of pages.");
return false;
}
}
// Main function to search for the username and navigate pages if not found
function searchUntilFound() {
// Always update dropdowns at the start of each cycle
updateDropdownsInForm();
const found = searchAndClickButton();
if (!found) {
const nextExists = clickNextButton(searchUntilFound);
if (!nextExists) {
console.log("No more pages to search. Username not found.");
}
}
}
// Function to run the full process
function runWorkflow() {
console.log("Starting workflow...");
inputURL(() => {
clickSearchButton(() => {
clickWButton(() => {
searchUntilFound();
});
});
});
// Schedule the next run in 70 seconds
setTimeout(runWorkflow, 70000); // 70 seconds = 70000 ms
}
// Start the process
runWorkflow();
// Made by github.com/zebbern