-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
256 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
{ | ||
"dependencies": { | ||
"axios": "^1.7.7", | ||
"https-proxy-agent": "^7.0.5" | ||
"https-proxy-agent": "^7.0.5", | ||
"socks-proxy-agent": "^8.0.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
http://username:password@host:port | ||
http://username:password@host2:port2 | ||
http://user:pass@host:port | ||
https://user:pass@host:port | ||
socks4://user:pass@host:port | ||
socks5://user:pass@host:port | ||
|
||
1 proxy 1 user | ||
IF YOU DO NOT NEED TO USE A PROXY, JUST DON'T FILL IN THE proxy.txt FILE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const querystring = require("querystring"); | ||
|
||
class UserAgentManager { | ||
constructor( | ||
tokensFile = "data.txt", | ||
userAgentsFile = "user_agents.json", | ||
userAgentsListFile = "user_agents_list.txt" | ||
) { | ||
this.tokensFile = tokensFile; | ||
this.userAgentsFile = userAgentsFile; | ||
this.userAgentsListFile = userAgentsListFile; | ||
} | ||
|
||
readFileLines(filePath) { | ||
try { | ||
return fs | ||
.readFileSync(filePath, "utf-8") | ||
.split("\n") | ||
.filter((line) => line.trim() !== ""); | ||
} catch (error) { | ||
console.error(`File reading error ${filePath}: ${error.message}`); | ||
return []; | ||
} | ||
} | ||
|
||
generateUserAgent(availableUserAgents) { | ||
if (availableUserAgents.length === 0) { | ||
return "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"; | ||
} | ||
|
||
const randomIndex = Math.floor(Math.random() * availableUserAgents.length); | ||
return availableUserAgents[randomIndex].trim(); | ||
} | ||
|
||
extractFirstName(initData) { | ||
try { | ||
return JSON.parse(decodeURIComponent(querystring.parse(initData).user))?.first_name; | ||
} catch (error) { | ||
console.error("Name extraction error:", error); | ||
return null; | ||
} | ||
} | ||
|
||
initializeUserAgents() { | ||
const tokens = this.readFileLines(this.tokensFile); | ||
const availableUserAgents = this.readFileLines(this.userAgentsListFile); | ||
|
||
let userAgents = {}; | ||
if (fs.existsSync(this.userAgentsFile)) { | ||
try { | ||
userAgents = JSON.parse(fs.readFileSync(this.userAgentsFile, "utf-8")); | ||
} catch (error) { | ||
console.warn("Failure to read existing user_agents.json, creation of a new one"); | ||
} | ||
} | ||
|
||
tokens.forEach((token) => { | ||
const firstName = this.extractFirstName(token); | ||
if (firstName && !userAgents[firstName]) { | ||
userAgents[firstName] = this.generateUserAgent(availableUserAgents); | ||
} | ||
}); | ||
|
||
fs.writeFileSync(this.userAgentsFile, JSON.stringify(userAgents, null, 2), "utf-8"); | ||
|
||
return userAgents; | ||
} | ||
|
||
getUserAgent(token) { | ||
const userAgents = this.initializeUserAgents(); | ||
const firstName = this.extractFirstName(token); | ||
|
||
return firstName ? userAgents[firstName] : null; | ||
} | ||
} | ||
|
||
module.exports = UserAgentManager; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 | ||
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 | ||
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:132.0) Gecko/20100101 Firefox/132.0 | ||
Mozilla/5.0 (Macintosh; Intel Mac OS X 14.7; rv:132.0) Gecko/20100101 Firefox/132.0 | ||
Mozilla/5.0 (X11; Linux i686; rv:132.0) Gecko/20100101 Firefox/132.0 | ||
Mozilla/5.0 (X11; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0 | ||
Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:132.0) Gecko/20100101 Firefox/132.0 | ||
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0 | ||
Mozilla/5.0 (X11; Fedora; Linux x86_64; rv:132.0) Gecko/20100101 Firefox/132.0 | ||
Mozilla/5.0 (Macintosh; Intel Mac OS X 14_7_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Safari/605.1.15 | ||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0) | ||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0) | ||
Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0) | ||
Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.0; Trident/5.0) | ||
Mozilla/4.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0) | ||
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0) | ||
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0) | ||
Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko | ||
Mozilla/5.0 (Windows NT 6.2; Trident/7.0; rv:11.0) like Gecko | ||
Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko | ||
Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko | ||
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/130.0.2849.80 | ||
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Edg/130.0.2849.80 | ||
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/114.0.0.0 | ||
Mozilla/5.0 (Windows NT 10.0; WOW64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/114.0.0.0 | ||
Mozilla/5.0 (Macintosh; Intel Mac OS X 14_7_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/114.0.0.0 | ||
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 OPR/114.0.0.0 | ||
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Vivaldi/7.0.3495.14 | ||
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Vivaldi/7.0.3495.14 | ||
Mozilla/5.0 (Macintosh; Intel Mac OS X 14_7_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Vivaldi/7.0.3495.14 | ||
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Vivaldi/7.0.3495.14 | ||
Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36 Vivaldi/7.0.3495.14 | ||
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 YaBrowser/24.10.1.669 Yowser/2.5 Safari/537.36 | ||
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 YaBrowser/24.10.1.669 Yowser/2.5 Safari/537.36 | ||
Mozilla/5.0 (iPhone; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/131.0.6778.73 Mobile/15E148 Safari/604.1 | ||
Mozilla/5.0 (iPad; CPU OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/131.0.6778.73 Mobile/15E148 Safari/604.1 | ||
Mozilla/5.0 (iPod; CPU iPhone OS 17_7 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/131.0.6778.73 Mobile/15E148 Safari/604.1 | ||
Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.39 Mobile Safari/537.36 | ||
Mozilla/5.0 (iPhone; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/132.0 Mobile/15E148 Safari/605.1.15 | ||
Mozilla/5.0 (iPad; CPU OS 14_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) FxiOS/132.0 Mobile/15E148 Safari/605.1.15 | ||
Mozilla/5.0 (iPod touch; CPU iPhone OS 14_7_1 like Mac OS X) AppleWebKit/604.5.6 (KHTML, like Gecko) FxiOS/132.0 Mobile/15E148 Safari/605.1.15 | ||
Mozilla/5.0 (Android 15; Mobile; rv:132.0) Gecko/132.0 Firefox/132.0 | ||
Mozilla/5.0 (Android 15; Mobile; LG-M255; rv:132.0) Gecko/132.0 Firefox/132.0 | ||
Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1 | ||
Mozilla/5.0 (iPad; CPU OS 17_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1 | ||
Mozilla/5.0 (iPod touch; CPU iPhone 17_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 Mobile/15E148 Safari/604.1 | ||
Mozilla/5.0 (Linux; Android 10; HD1913) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.39 Mobile Safari/537.36 EdgA/130.0.2849.80 | ||
Mozilla/5.0 (Linux; Android 10; SM-G973F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.39 Mobile Safari/537.36 EdgA/130.0.2849.80 | ||
Mozilla/5.0 (Linux; Android 10; Pixel 3 XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.39 Mobile Safari/537.36 EdgA/130.0.2849.80 | ||
Mozilla/5.0 (Linux; Android 10; ONEPLUS A6003) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.39 Mobile Safari/537.36 EdgA/130.0.2849.80 | ||
Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 EdgiOS/130.2849.80 Mobile/15E148 Safari/605.1.15 | ||
Mozilla/5.0 (Windows Mobile 10; Android 10.0; Microsoft; Lumia 950XL) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Mobile Safari/537.36 Edge/40.15254.603 | ||
Mozilla/5.0 (Linux; Android 10; VOG-L29) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.39 Mobile Safari/537.36 OPR/76.2.4027.7337 | ||
Mozilla/5.0 (Linux; Android 10; SM-G970F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.39 Mobile Safari/537.36 OPR/76.2.4027.73374 | ||
Mozilla/5.0 (Linux; Android 10; SM-N975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.39 Mobile Safari/537.36 OPR/76.2.4027.73374 | ||
Mozilla/5.0 (iPhone; CPU iPhone OS 17_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 YaBrowser/24.10.5.295 Mobile/15E148 Safari/604.1 | ||
Mozilla/5.0 (iPad; CPU OS 17_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 YaBrowser/24.10.5.295 Mobile/15E148 Safari/605.1 | ||
Mozilla/5.0 (iPod touch; CPU iPhone 17_7_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.0 YaBrowser/24.10.5.295 Mobile/15E148 Safari/605.1 | ||
Mozilla/5.0 (Linux; arm_64; Android 15; SM-G965F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.6778.39 YaBrowser/24.10.4.98 Mobile Safari/537.36 |