Skip to content

Instantly share code, notes, and snippets.

@MagicalBlob
Created January 31, 2022 20:57
Show Gist options
  • Save MagicalBlob/f130b940c1c08658ae4417c546377aa6 to your computer and use it in GitHub Desktop.
Save MagicalBlob/f130b940c1c08658ae4417c546377aa6 to your computer and use it in GitHub Desktop.
Script to send NationStates.net's World Assembly endorsement requests because I'm lazy yet keep "playing" this browser game for some unknown reason
// ==UserScript==
// @name NationStates mass endorsing
// @namespace Violentmonkey Scripts
// @match https://www.nationstates.net/nation=*
// @grant none
// @version 1.0
// @author -
// @description 1/31/2022, 8:18:36 PM
// ==/UserScript==
// Create the button
var endorseAllButton = document.createElement("button");
endorseAllButton.type = "button";
endorseAllButton.className = "endorse button icon wa";
endorseAllButton.textContent = "Endorse all";
endorseAllButton.onclick = function() {
var localID = this.parentNode.parentNode.localid.value;
fetch("https://cerulean.nsr3n.info/europeia_endotarting_queries/get_daemon.sh?format=full&region=europeia&query=!endorsedby%3Abrickfield&format=csv").then((value) => value.text().then(function(text) {
var nations = text.split(',');
for (var i = 0; i < nations.length; i++) {
fetch("https://www.nationstates.net/cgi-bin/endorse.cgi", {
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"body": "nation=" + nations[i] + "&localid=" + localID + "&action=endorse"
});
}
}));
}
// Add button to the page
var forms = document.getElementsByTagName("form");
for (var form = 0; form < forms.length; form++) {
if (forms[form].attributes.action.nodeValue == "/cgi-bin/endorse.cgi") {
forms[form].children[3].appendChild(endorseAllButton);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment