diff --git a/GrepolisRemoteControl.user.js b/GrepolisRemoteControl.user.js
index 8f9c8e5..3f15cbd 100644
--- a/GrepolisRemoteControl.user.js
+++ b/GrepolisRemoteControl.user.js
@@ -480,6 +480,11 @@
const isLocked = status === 0;
const action = isLocked ? 'unlock' : 'upgrade';
+ const requestedAction = cmd.payload?.action_type;
+ if (requestedAction && requestedAction !== action) {
+ skipped++; continue;
+ }
+
log(`Farm ${action}: farm_id=${farm.attributes.id} level=${level} town=${town_id}`);
try {
uw.gpAjax.ajaxPost('frontend_bridge', 'execute', {
diff --git a/templates/farm.html b/templates/farm.html
index b591aff..a0e542d 100644
--- a/templates/farm.html
+++ b/templates/farm.html
@@ -292,8 +292,13 @@
-
- Εντολή εστάλη!
+
+
+
+
+
+ Εντολή εστάλη!
+
@@ -426,17 +431,30 @@
// -- Live Sync --
function requestSync() {
+ const btn = document.querySelector('.sync-btn');
+ const originalText = btn.innerText;
+ btn.innerText = '⏳ Syncing...';
+ btn.disabled = true;
+
fetch(`/api/sync-request?player_id=${PLAYER_ID}`, { method: 'POST' })
.then(r => r.json())
.then(data => {
- // Will get a fast state update
- setTimeout(loadFarmData, 1500);
+ setTimeout(() => {
+ loadFarmData();
+ btn.innerText = originalText;
+ btn.disabled = false;
+ }, 1500);
});
}
- // -- Trigger Upgrade --
- function triggerUpgrade() {
+ // -- Trigger Upgrade / Unlock --
+ function triggerUpgrade(actionType) {
const threshold = document.getElementById('kp-threshold').value;
+ const btn = actionType === 'unlock' ? document.getElementById('unlock-btn') : document.getElementById('upgrade-btn');
+ const originalText = btn.innerText;
+ btn.innerText = '⏳ Αποστολή...';
+ btn.disabled = true;
+
fetch('/dashboard/commands', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
@@ -444,11 +462,13 @@
player_id: PLAYER_ID,
town_id: 0,
type: 'farm_upgrade',
- payload: { threshold: threshold }
+ payload: { threshold: threshold, action_type: actionType }
})
})
.then(r => r.json())
.then(() => {
+ btn.innerText = originalText;
+ btn.disabled = false;
const s = document.getElementById('upgrade-status');
s.classList.add('visible');
setTimeout(() => s.classList.remove('visible'), 3000);