by Max Barry

Latest Forum Topics

Advertisement

14

DispatchMetaReference

by The Mergelland of Riemst. . 325 reads.

Some small scripts that can improve your card-farming experience.

A small Tampermonkey script that kicks in when you attempt to load an issue in a firefox container (with a card-farming-script). It fills in the password, checks the "remember me"-checkbox and sets focus to the "login"-button.
Copy your list in the NationPW array in the same format as in the example. For nationnames: use only lowercase and replace all spaces with underscores.

// ==UserScript==
// ==UserScript==
// @name         Cure for the Lost Container Syndrom
// @version      0.1
// @description  Cures logged out containers
// @author       Riemstagrad
// @noframes
// @match        https://www.nationstates.net/page=enact_dilemma/*
// @match        https://www.nationstates.net/container=*page=dilemmas*
// @grant        none
// ==/UserScript==


(function () {
    'use strict';
    var i;
    let NationPW = [
        'nationname','password',
        'nationname_2','password2'
];
// ^put your nationnames and passwords there, in this format. For nationnames: use underscores instead of spaces and all characters in lowercase.

    if(document.getElementsByClassName("button icon primary").length > 0){
    for (i = 0; i < NationPW.length; i +=2 ) {
        if (document.querySelector("input[name=\"nation").value == NationPW[i]){
            document.querySelector("input[name=\"password").value = NationPW[i+1]
          }};
    document.querySelector("input[name=\"autologin").checked = true;
    document.querySelector("button[value=\"Login").focus();
    }

})();

If you have your nations with their passwords stored in a spreadsheet, you can generate a list in the correct format with the following function:

=IF(E$1="Y";SUBSTITUTE(CONCATENATE("'";LOWER(A1);"','";B1;"',");" ";"_");CONCATENATE(A1;",";B1))

In this funtion the nationnames are in collumn A and the passwords in collumn B and the function goes in collumn C. In cell E1 there is a switch that lets you switch between the format for the above script (if value of cell E1 = "Y") or a format you can paste into Racoda's Gold Retriever or 9003's Gotissues (if value of cell E1 is anything but not "Y")
This function works in OpenOffice Calc.

The following script assists with gifting cards to a bunch of nation. Easy for when you have collections on multiple nations. Just edit the "moustrap..." lines in the script and/or add more. When on the Gift-page, you just use the keybinds to auto-fill in a nation-name and set focus to gift button.

// ==UserScript==
// @name         Card Gift Keybinds
// @version      0.3
// @namespace    Riem
// @description  assign nations to keybinds for quick gifting
// @author       Riemstagrad
// @noframes
// @match        https://www.nationstates.net/*page=deck*/gift=*
// @require      https://craig.global.ssl.fastly.net/js/mousetrap/mousetrap.min.js?a4098
// @grant        none
// ==/UserScript==


(function () {
    'use strict';

//To add more keys, copy/paste and edit one of the lines below.
    
    Mousetrap.bind('c', function() { GiftTo('cards server donations');});
    Mousetrap.bind('d', function() { GiftTo('deck space'); });
    Mousetrap.bind('k', function() { GiftTo('Kwisatz Carderach'); });
    Mousetrap.bind('m', function() { GiftTo('Gerardus Mercator'); });
    Mousetrap.bind('s', function() { GiftTo('The North Pacific S3'); });
    Mousetrap.bind('u', function() { GiftTo('cartagriem 011');});
    Mousetrap.bind('v', function() { GiftTo('vylixan dora');});


    function GiftTo(name) {
    document.querySelector("input[name=\"entity_name\"").value = name;
    document.querySelector("button[name=\"send_gift\"").focus();
    }

})()

Another small thing to make life easier when creating a collection from a lot of cards. Basically this thing just checks all checkboxes on a page. It's brutal, but it speeds up the tedious work. Rebember to switch it off when doing something else.

// ==UserScript==
// @name         check all boxes
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Riemstagrad
// @match        https://www.nationstates.net/*
// @icon         https://www.google.com/s2/favicons?domain=nationstates.net
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
   // var cboxes;
   // var i;
   // cboxes = document.getElementsbyname("checkbox");
   // for (i = 1;i< cboxes.length;i+=1) {
   //     cboxes[i].checked = true;
   // }
    checkThem([].slice.call(document.querySelectorAll('input[type="checkbox"]')));
    function checkThem(nodes) {
    nodes.forEach(function(n) { n.checked = true })
    }
    incthem([].slice.call(document.querySelectorAll('input[type="number"]')));
    function incthem(nodes) {
    nodes.forEach(function(n) { n.value = 1;n.disabled = false })
    }
    //document.getElementByName("save_collection").focus();
    document.querySelector("button[name=\"save_collection").focus();
  //  document.querySelector("button[type=\"Login").focus();
})();

A script to assist in adding all cards on a nation to a collection: in your collection, click the edit button, the scrip will select all radio-buttons and set focus to the Save-button. Hit Enter and then 'n' to go to the next page. Hit 'enter' then 'n' until the end.

// ==UserScript==
// @name         AddEverythingToCollection
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       Riemstagrad
// @match        https://www.nationstates.net/page=deck/*collection=*
// @require      https://craig.global.ssl.fastly.net/js/mousetrap/mousetrap.min.js?a4098
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    checkThem([].slice.call(document.querySelectorAll('input[type="checkbox"]')));
    function checkThem(nodes) {
    nodes.forEach(function(n) { n.checked = true })
    }
    incthem([].slice.call(document.querySelectorAll('input[type="number"]')));
    function incthem(nodes) {
    nodes.forEach(function(n) { n.value = 1;n.disabled = false })
    }
    document.querySelector("button[name=\"save_collection").focus();
    function noinput_mousetrap(event) {
        if (event.target.classList.contains("mousetrap")) {
            event.preventDefault();
            event.stopPropagation();
        }
    }
            Mousetrap.bind(['n', 'N'], function(event) {
                  document.evaluate("//a[text()='»']", document).iterateNext().click()

    });
})();

Riemstagrad

The Mergelland of Riemst

Edited:

RawReport