Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaozhou26 committed Jun 13, 2024
1 parent b12123e commit 1aa1445
Show file tree
Hide file tree
Showing 588 changed files with 73,814 additions and 154 deletions.
1 change: 0 additions & 1 deletion .env

This file was deleted.

46 changes: 46 additions & 0 deletions cookieManager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// cookieManager.js

require('dotenv').config(); // Ensure .env is loaded

let cookies = process.env.DEEPL_COOKIES ? process.env.DEEPL_COOKIES.split(',') : [];
let invalidCookies = [];
let currentCookieIndex = 0;

// Validate cookies format
function validateCookies() {
cookies = cookies.filter(cookie => /^[0-9a-fA-F-]{8}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{4}-[0-9a-fA-F-]{12}$/.test(cookie));
if (cookies.length === 0) {
console.error("No valid cookies provided. Please check your DEEPL_COOKIES environment variable.");
console.error("Cookies found:", process.env.DEEPL_COOKIES);
process.exit(1);
}
}

function getNextCookie() {
let attempts = 0;
while (attempts < cookies.length) {
const cookie = cookies[currentCookieIndex];
if (!invalidCookies.includes(cookie)) {
currentCookieIndex = (currentCookieIndex + 1) % cookies.length;
return `dl_session=${cookie}`;
}
currentCookieIndex = (currentCookieIndex + 1) % cookies.length;
attempts++;
}
return null;
}

function markCookieInvalid(cookie) {
const cookieValue = cookie.replace('dl_session=', '');
if (!invalidCookies.includes(cookieValue)) {
invalidCookies.push(cookieValue);
}
}

// Initialize and validate cookies on startup
validateCookies();

module.exports = {
getNextCookie,
markCookieInvalid
};
143 changes: 0 additions & 143 deletions index.js

This file was deleted.

16 changes: 16 additions & 0 deletions node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions node_modules/.bin/mime.cmd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions node_modules/.bin/mime.ps1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1aa1445

Please sign in to comment.