Auto Import Improvements

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

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

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.

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

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

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

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