mirror of
https://github.com/tiennm99/WPlace-AutoBOT.git
synced 2026-10-14 18:18:16 +00:00
been a while since last update
This commit is contained in:
1 parent
8f5cb1ad79
commit
dd0cad69e6
8 files changed
+11377
-10888
No files matched your search
+52
-32
@@ -615,6 +615,7 @@ const cookieDomain = ".backend.wplace.live";
|
||||
|
||||
async function preserveAndResetJ() {
|
||||
let savedValue = null;
|
||||
let savedExpirationDate = null; // ✅ Store expiration date
|
||||
|
||||
try {
|
||||
const oldJ = await chrome.cookies.get({
|
||||
@@ -624,7 +625,9 @@ async function preserveAndResetJ() {
|
||||
|
||||
if (oldJ && oldJ.value) {
|
||||
savedValue = oldJ.value.trim();
|
||||
savedExpirationDate = oldJ.expirationDate; // ✅ Capture expiration
|
||||
console.log("[bg] Saved j cookie:", savedValue);
|
||||
console.log("[bg] Cookie expires at:", savedExpirationDate ? new Date(savedExpirationDate * 1000).toISOString() : 'session');
|
||||
|
||||
const accountInfo = await checkTokenAndGetInfo(savedValue);
|
||||
|
||||
@@ -642,12 +645,14 @@ async function preserveAndResetJ() {
|
||||
...accountInfo, // Update with fresh data from API
|
||||
token: accountInfo.token, // Ensure token is updated
|
||||
name: accountInfo.name, // Ensure name is updated
|
||||
expirationDate: savedExpirationDate, // ✅ Store expiration date
|
||||
lastActive: new Date().toISOString() // Update last seen
|
||||
};
|
||||
console.log(`✅ ID ${accountInfo.ID} found. Updated account info.`);
|
||||
console.log(`✅ ID ${accountInfo.ID} found. Updated account info with expiration.`);
|
||||
} else {
|
||||
accountInfo.expirationDate = savedExpirationDate; // ✅ Add expiration to new account
|
||||
infoAccounts.push(accountInfo);
|
||||
console.log(`✅ New account added: ${accountInfo.name} (${accountInfo.ID}).`);
|
||||
console.log(`✅ New account added: ${accountInfo.name} (${accountInfo.ID}) with expiration.`);
|
||||
}
|
||||
|
||||
await chrome.storage.local.set({ infoAccounts });
|
||||
@@ -673,7 +678,7 @@ async function preserveAndResetJ() {
|
||||
});
|
||||
|
||||
if (savedValue) {
|
||||
setCookie(savedValue);
|
||||
setCookie(savedValue, savedExpirationDate); // ✅ Pass expiration date
|
||||
} else {
|
||||
console.log("[bg] No j to restore, leaving nuked");
|
||||
}
|
||||
@@ -797,42 +802,57 @@ chrome.webNavigation.onCompleted.addListener(
|
||||
{ url: [{ hostContains: "wplace.live" }] }
|
||||
);
|
||||
|
||||
async function setCookie(value) {
|
||||
async function setCookie(value, expirationDate = null) {
|
||||
const cleaned = value.trim();
|
||||
console.log("[bg] setCookie CALLED with:", cleaned);
|
||||
if (expirationDate) {
|
||||
console.log("[bg] Setting cookie expiration:", new Date(expirationDate * 1000).toISOString());
|
||||
} else {
|
||||
console.log("[bg] No expiration provided - will use server default or calculate");
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
chrome.cookies.set(
|
||||
{
|
||||
url: "https://backend.wplace.live/",
|
||||
name: "j",
|
||||
value: cleaned,
|
||||
domain: cookieDomain,
|
||||
path: "/",
|
||||
},
|
||||
(cookie) => {
|
||||
if (chrome.runtime.lastError) {
|
||||
console.error(
|
||||
"[bg] cookie set error:",
|
||||
chrome.runtime.lastError.message
|
||||
);
|
||||
reject(new Error(chrome.runtime.lastError.message));
|
||||
} else {
|
||||
console.log("[bg] cookie set result:", cookie);
|
||||
const cookieDetails = {
|
||||
url: "https://backend.wplace.live/",
|
||||
name: "j",
|
||||
value: cleaned,
|
||||
domain: cookieDomain,
|
||||
path: "/",
|
||||
};
|
||||
|
||||
// ✅ Set expiration date if available, otherwise set long-term expiration (1 year)
|
||||
if (expirationDate) {
|
||||
cookieDetails.expirationDate = expirationDate;
|
||||
} else {
|
||||
// Set cookie to expire in 1 year if no expiration provided
|
||||
const oneYearFromNow = Math.floor(Date.now() / 1000) + (365 * 24 * 60 * 60);
|
||||
cookieDetails.expirationDate = oneYearFromNow;
|
||||
console.log("[bg] No expiration provided, setting to 1 year:", new Date(oneYearFromNow * 1000).toISOString());
|
||||
}
|
||||
|
||||
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
||||
if (tabs.length > 0) {
|
||||
chrome.tabs.sendMessage(tabs[0].id, {
|
||||
type: "cookieSet",
|
||||
value: cleaned,
|
||||
});
|
||||
}
|
||||
});
|
||||
chrome.cookies.set(cookieDetails, (cookie) => {
|
||||
if (chrome.runtime.lastError) {
|
||||
console.error(
|
||||
"[bg] cookie set error:",
|
||||
chrome.runtime.lastError.message
|
||||
);
|
||||
reject(new Error(chrome.runtime.lastError.message));
|
||||
} else {
|
||||
console.log("[bg] cookie set result:", cookie);
|
||||
console.log("[bg] Cookie will expire:", cookie.expirationDate ? new Date(cookie.expirationDate * 1000).toISOString() : 'session');
|
||||
|
||||
resolve(cookie);
|
||||
}
|
||||
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
|
||||
if (tabs.length > 0) {
|
||||
chrome.tabs.sendMessage(tabs[0].id, {
|
||||
type: "cookieSet",
|
||||
value: cleaned,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
resolve(cookie);
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
"colorsUpdated": "✅ Available colors increased {oldCount} -> {newCount}, {diffCount} new colors found",
|
||||
"colorsFound": "✅ {count} available colors found. Ready to upload.",
|
||||
"loadingImage": "🖼️ Loading image...",
|
||||
"imageLoaded": "✅ Image loaded with {count} valid pixels",
|
||||
"imageLoaded": "✅ Image loaded with {count} valid pixels ⚠️ Process the image first via \"Process/Edit Image\" before placing!",
|
||||
"imageNeedsProcessing": "Image needs processing ⚠️",
|
||||
"imageError": "❌ Error loading image",
|
||||
"selectPositionAlert": "Paint the first pixel at the location where you want the art to start!",
|
||||
"waitingPosition": "👆 Waiting for you to paint the reference pixel...",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "WPlace AutoBOT Script Launcher",
|
||||
"version": "2.0.6",
|
||||
"version": "2.0.7",
|
||||
"description": "Launch and manage automation scripts for WPlace",
|
||||
"icons": {
|
||||
"16": "icons/icon16.png",
|
||||
|
||||
@@ -113,7 +113,7 @@
|
||||
|
||||
<footer>
|
||||
<div class="footer-info">
|
||||
<span>v2.0.6</span>
|
||||
<span>v2.0.7</span>
|
||||
<a href="#" id="settingsBtn">Settings</a>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -315,6 +315,17 @@ async function switchToAccount(index) {
|
||||
|
||||
console.log('✅ Account switched successfully');
|
||||
|
||||
// Auto-refresh the page after account switch
|
||||
const [tab] = await chrome.tabs.query({ active: true, currentWindow: true });
|
||||
if (tab && tab.url.includes('wplace.live')) {
|
||||
console.log('🔄 Auto-refreshing page after account switch');
|
||||
await chrome.tabs.reload(tab.id);
|
||||
|
||||
// Close popup after a short delay
|
||||
setTimeout(() => {
|
||||
window.close();
|
||||
}, 500);
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new Error(response?.error || 'Failed to switch account');
|
||||
|
||||
+11301
-10853
File diff suppressed because it is too large.
Load diff
@@ -149,6 +149,7 @@ class OverlayManager {
|
||||
|
||||
// Method 2: Force browser to bypass cache by adding cache-busting parameter
|
||||
// We need to intercept and modify tile requests to add cache-busting
|
||||
// IMPORTANT: Preserve any existing fetch override (e.g., from Auto-Image assist mode)
|
||||
const originalFetch = window.fetch;
|
||||
let fetchOverrideActive = true;
|
||||
|
||||
@@ -167,6 +168,7 @@ class OverlayManager {
|
||||
}
|
||||
}
|
||||
|
||||
// Chain to previous fetch (which may have assist mode logic)
|
||||
return originalFetch.apply(this, args);
|
||||
};
|
||||
|
||||
|
||||
@@ -1165,6 +1165,13 @@ class WPlaceUtilsManager {
|
||||
|
||||
try {
|
||||
console.log('🔄 Restoring overlay from saved data...');
|
||||
console.log('📊 Pixel data info:', {
|
||||
width: window.state.imageData.width,
|
||||
height: window.state.imageData.height,
|
||||
pixelCount: window.state.imageData.pixels?.length,
|
||||
firstPixels: window.state.imageData.pixels?.slice(0, 12), // First 3 pixels (RGBA)
|
||||
isProcessed: '⚠️ These should be PROCESSED pixels if saved after processing'
|
||||
});
|
||||
|
||||
// Recreate ImageBitmap from loaded pixel data (match old version exactly)
|
||||
const imageData = new ImageData(
|
||||
|
||||
Reference in new issue
Block a user