-
-
Save Sitethief/721bd55e5596c4777eb19749a4d2aa1c to your computer and use it in GitHub Desktop.
Hides the move regions button/text from configured nations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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