Auto Import Improvements

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

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