Skip to content

Instantly share code, notes, and snippets.

@Sitethief
Last active September 4, 2022 08:14
Show Gist options
  • Save Sitethief/4616fdf928ccc9a28ffbb1ac636afcfe to your computer and use it in GitHub Desktop.
Save Sitethief/4616fdf928ccc9a28ffbb1ac636afcfe to your computer and use it in GitHub Desktop.
Tweaks for the Gift page
// ==UserScript==
// @name NSGiftPageTweaks
// @namespace sitethiefs-ns-scripts
// @version 0.2
// @description Tweaks for the Gift page
// @author Sitethief of Vylixan
// @copyright GPLv3 https://www.gnu.org/licenses/gpl-3.0.html
// @match https://www.nationstates.net/*/gift=1
// @icon https://www.google.com/s2/favicons?domain=nationstates.net
// @grant none
// ==/UserScript==
(function () {
'use strict';
let options = {
immediateGift: true,
}
let giftNations = [
];
let input = document.getElementById('entity_name');
if (input) {
input.focus();
}
let giftButton = document.querySelector('button[name="send_gift"]');
let content = document.querySelector('#content');
let giftContainer = document.createElement('div');
giftContainer.style.marginLeft = '350px';
for (let i = 0; i < giftNations.length; i++) {
let giftListItem = document.createElement('span');
giftListItem.style.margin = '5px';
giftListItem.style.display = 'inline-block';
let giftListItemButton = document.createElement('button');
giftListItemButton.innerHTML = giftNations[i];
giftListItemButton.type = 'button';
giftListItemButton.addEventListener(
"click",
function (event) {
input.value = giftNations[i];
giftButton.focus()
if (options.immediateGift) {
giftButton.click();
}
},
false
);
giftListItem.appendChild(giftListItemButton);
giftContainer.appendChild(giftListItem);
}
content.appendChild(giftContainer);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment