Auto Import Improvements

Automatically imports improvements if the import string is passed in as a comma separated string of values

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name        Auto Import Improvements
// @namespace   https://politicsandwar.com/n/Talus
// @match       https://politicsandwar.com/city/improvements/import/id=*&c=*
// @grant       none
// @version     1.0
// @author      Talus
// @description Automatically imports improvements if the import string is passed in as a comma separated string of values
// @license     GPL-3.0-or-later
// ==/UserScript==

if (document.querySelector('.alert.alert-success') != null) {
  // Import already performed
  return;
}
if (document.querySelector('.alert.alert-danger') != null) {
  // Check import requirements
  return;
}
var improvementNames = ["infra_needed","imp_total","imp_coalpower","imp_oilpower","imp_windpower","imp_nuclearpower","imp_coalmine","imp_oilwell","imp_uramine","imp_leadmine","imp_ironmine","imp_bauxitemine","imp_farm","imp_gasrefinery","imp_aluminumrefinery","imp_munitionsfactory","imp_steelmill","imp_policestation","imp_hospital","imp_recyclingcenter","imp_subway","imp_supermarket","imp_bank","imp_mall","imp_stadium","imp_barracks","imp_factory","imp_hangars","imp_drydock"];
var urlParams = new URLSearchParams(window.location.href);
var improvementsNumbers = urlParams.get('c');
var improvementsArray = improvementsNumbers .split(',');
var improvementsJson = {}
for (var i = 0; i < improvementsArray .length; i++) {
  improvementsJson[improvementNames [i]] = improvementsArray [i];
}
document.querySelector('textarea[name="imp_import"]').value = JSON.stringify(improvementsJson);
document.querySelector('input[name="imp_import_execute"]').click();