Skip to content

Instantly share code, notes, and snippets.

@Sitethief
Last active June 15, 2022 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sitethief/721bd55e5596c4777eb19749a4d2aa1c to your computer and use it in GitHub Desktop.
Save Sitethief/721bd55e5596c4777eb19749a4d2aa1c to your computer and use it in GitHub Desktop.
Hides the move regions button/text from configured nations
// ==UserScript==
// @name NSPreventMoving
// @namespace sitethiefs-ns-scripts
// @version 0.1.1
// @description Hides the move regions button/text from configured nations
// @author Sitethief of Vylixan
// @copyright GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
// @match *www.nationstates.net/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
/**
*
* Start of User customizable options
*
**/
/**
* These are the nations where you want to prevent moving
* format is as follows:
const nationsToPreventMoving = [
'Nation Name 1',
'Nation Name 2',
];
*/
const nationsToPreventMoving = [
];
/**
*
* End of User customizable options
*
**/
function canonicalize(name) {
return name.trim().toLowerCase().replace(/ /g, "_");
}
const body = document.getElementById("loggedin");
if (body) {
const canonicalizedNationsToPreventMoving = nationsToPreventMoving.map(x => canonicalize(x));
const currentNationKey = body.dataset.nname;
const nationMatch = canonicalizedNationsToPreventMoving.includes(currentNationKey);
const moveButton = document.querySelector('button[name=move_region]');
const tiredText = document.querySelector('a[href*="page=change_region"]');
if (nationMatch && moveButton) {
moveButton.parentNode.removeChild(moveButton);
}
if (nationMatch && tiredText) {
tiredText.parentNode.removeChild(tiredText);
}
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment