Auto Import Improvements

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

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

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

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

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

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

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

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.

(I already have a user style manager, let me install it!)

// ==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();