mirror of
https://github.com/tiennm99/WPlace-AutoBOT.git
synced 2026-10-11 03:13:01 +00:00
removed duplicate message listener
This commit is contained in:
1 parent
02bfff2c41
commit
08acdfc66f
2 files changed
+3
-26
No files matched your search
@@ -13,29 +13,6 @@ chrome.runtime.onInstalled.addListener(async () => {
|
||||
console.log('📦 Installation resource test:', resources);
|
||||
});
|
||||
|
||||
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
|
||||
if (request.action === 'executeScript') {
|
||||
// Get tabId from sender or requests
|
||||
const tabId = request.tabId || sender.tab?.id;
|
||||
|
||||
if (!tabId) {
|
||||
sendResponse({ success: false, error: 'Could not determine target tab' });
|
||||
return;
|
||||
}
|
||||
|
||||
// Use IIFE for async handlings
|
||||
(async () => {
|
||||
try {
|
||||
await executeLocalScript(request.scriptName, tabId);
|
||||
sendResponse({ success: true });
|
||||
} catch (error) {
|
||||
sendResponse({ success: false, error: error.message });
|
||||
}
|
||||
})();
|
||||
|
||||
return true; // Important: indicates async response
|
||||
}
|
||||
});
|
||||
|
||||
async function executeLocalScript(scriptName, tabId) {
|
||||
try {
|
||||
|
||||
@@ -4410,7 +4410,7 @@ localStorage.removeItem("lp");
|
||||
const timeText = Utils.msToTimeText(remainingMs);
|
||||
|
||||
if (currentChargesEl) {
|
||||
currentChargesEl.innerHTML = `${state.displayCharges} / ${state.maxCharges}`;
|
||||
currentChargesEl.innerHTML = `${state.displayCharges} / ${max}`;
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -4608,7 +4608,7 @@ localStorage.removeItem("lp");
|
||||
totalMaxCharges = accounts.reduce((sum, acc) => {
|
||||
if (currentAccount && acc.token === currentAccount.token) {
|
||||
// Use real-time max charges for current account
|
||||
return sum + Math.floor(state.maxCharges || acc.Max || 0);
|
||||
return sum + Math.floor((state.fullChargeData?.max ?? state.maxCharges ?? acc.Max ?? 0));
|
||||
} else {
|
||||
// Use stored data for other accounts
|
||||
return sum + Math.floor(acc.Max || 0);
|
||||
@@ -4633,7 +4633,7 @@ localStorage.removeItem("lp");
|
||||
<i class="fas fa-bolt"></i> ${Utils.t('charges')}
|
||||
</div>
|
||||
<div class="wplace-stat-value" id="wplace-stat-charges-value">
|
||||
${state.displayCharges} / ${state.maxCharges}
|
||||
${state.displayCharges} / ${state.fullChargeData?.max ?? state.maxCharges}
|
||||
</div>
|
||||
</div>
|
||||
<div class="wplace-stat-item">
|
||||
|
||||
Reference in new issue
Block a user