NATION

PASSWORD

Card Scripts including JUNKER (follows the 1:1 rule)

The place to wheel and deal, talk shop, and build up your dream deck!
User avatar
9003
Diplomat
 
Posts: 624
Founded: Oct 25, 2012
Corporate Police State

Card Scripts including JUNKER (follows the 1:1 rule)

Postby 9003 » Mon May 11, 2020 10:09 am

Hello there!

Most of you know me as that crazy guy who collects way to many commons, some of you even know me from the cards discord (Shameless plug check it out here https://forum.nationstates.net/viewtopic.php?f=42&t=458820) In the discord I offer lots of great advice and a few tools, as such I wanted to share those tools with the greater community just in case you are not in the discord but still farm cards and want some super duper useful tools! If you need help setting them up or making them work shoot me a message or join the discord they are all super helpful folks.

To install the User script the first step you will need is tampermonkey

Let me just google that for you and explain the internet

Once tamper monkey is installed make a new userscript and copy and paste the following into that window.


Code: Select all
// ==UserScript==
// @name         Key code short cuts
// @version      0.1.1
// @namespace    dithpri.RCES
// @description  mousetrap keybinds for card page
// @author       dithpri Moded by 9003
// @noframes
// @match        https://www.nationstates.net/*page=deck*card=*
// @match        https://www.nationstates.net/page=deck
// @match        https://www.nationstates.net/*card=*page=deck*
// @match        https://www.nationstates.net/nation=*/page=deck/value_deck=1/template-overall=none
// @match        https://www.nationstates.net/nation=*/page=deck
// @match        https://www.nationstates.net/nation=*/page=deck/value_deck=1/template-overall=none
// @require      https://craig.global.ssl.fastly.net/js/mousetrap/mousetrap.min.js?a4098
// @grant        window.close
// ==/UserScript==

/*
 * Keybinds:
 * [s]ell, [a]sk
 * [b]uy, [b]id

 * [m]atch
 * [o]pen
 * [r]ight now it'll close if you press 'r'
 * [t]o Deck page
 * [e]veryone hates useing 'e' to refresh a page rather then r
 * [f]lip 9003 off becuse you are so thankful for his code, and I guess it flips the cards
 * [j]unks all cards listed below the default is to junk Uncommons, Rares, Ultra rares.  You still need to press enter or space for the pop up
 */

(function() {
    'use strict';
    function noinput_mousetrap(event) {
        if (event.target.classList.contains("mousetrap")) {
            event.preventDefault();
            event.stopPropagation();
        }
    }

    const inputs = document.querySelectorAll("input.auctionbid[name=\"auction_ask\"], input.auctionbid[name=\"auction_bid\"]");
    let ask_match = document.querySelector("#highest_matchable_ask_price > .cardprice_sell");
    let bid_match = document.querySelector("#lowest_matchable_bid_price > .cardprice_buy");
    ask_match = ask_match ? ask_match.textContent : 0;
    bid_match = bid_match ? bid_match.textContent : 0;

    // sell, ask
    Mousetrap.bind(['s', 'a', 'S', 'A', 'l'], function(ev) {
        noinput_mousetrap(ev);
        document.querySelector("th[data-mode=\"sell\"").click();
        const askbox = document.querySelector("input.auctionbid[name=\"auction_ask\"]");
        askbox.focus(); askbox.select();
    });

    // buy, bid
    Mousetrap.bind(['b', 'B', 'k'], function(ev) {
        noinput_mousetrap(ev);
        document.querySelector("th[data-mode=\"buy\"").click();
        const bidbox = document.querySelector("input.auctionbid[name=\"auction_bid\"]");
        bidbox.focus(); bidbox.select();
    });
 

    // match sets the ask AND bid to match with the other one use with 'b' or 's' to auto buy or sell at the best price
    Mousetrap.bind(['m', 'M'], function(ev) {
        noinput_mousetrap(ev);
        if (ask_match && ask_match > 0) {
            document.querySelector("input.auctionbid[name=\"auction_ask\"]").value = ask_match;
        }
        if (bid_match && bid_match > 0) {
            document.querySelector("input.auctionbid[name=\"auction_bid\"]").value = bid_match;
        }
    });

     Mousetrap.bind(['o'],  function(ev){document.getElementsByClassName("button lootboxbutton")[0].click();});
     Mousetrap.bind(['r'],  function(ev){if(!window.location.href.endsWith("/auto")) window.close();});
    Mousetrap.bind(['t'],   function(ev){window.location.replace("https://www.nationstates.net/page=deck");});
    Mousetrap.bind(['e'],  function(ev){location.reload();});
     Mousetrap.bind(['f'],  function(ev){document.getElementsByClassName("back")[0].click();document.getElementsByClassName("back")[1].click();document.getElementsByClassName("back")[2].click();document.getElementsByClassName("back")[3].click();document.getElementsByClassName("back")[4].click(); });
 

//to junk commons just add a.deckcard-junk-button[data-rarity="common"] to the list below.
   Mousetrap.bind(['j'],  function(ev){let elem = document.querySelector('a.deckcard-junk-button[data-rarity="uncommon"], a.deckcard-junk-button[data-rarity="rare"], a.deckcard-junk-button[data-rarity="ultra-rare"]');
   if (elem) {
    elem.click();
    elem.classList.remove('deckcard-junk-button');
    elem.classList.add('disabled');
}});
    inputs.forEach(function(el) {
        // to be able to use keybinds while inputting numbers
        el.classList.add("mousetrap");
        // to submit on enter
        el.addEventListener('keypress', function(e) {
            if(e.which == 13) {
                this.parentNode.nextElementSibling.firstChild.click();
            }
        })
    });
})();


This lovely code adds lots of super useful things, from the top of the code you can see here what all it does

/*
* Keybinds:
* [s]ell, [a]sk - simple as can be it just opens the ask window and allows you to press enter to submit the current price in the window as an ask
* [b]uy, [b]id - also simple does the same as above but with the bid/buy window

* [m]atch - a fun one that you pair with a/b to match the current price meaning if a card is for sale at 10 bank and you press m b enter it will match the 10 and buy the card, if the card has a 10 bank bid you go s m enter to sell the card to the highest person.
* [o]pen - opens the pack of cards from the deck page
* [r]ight now it'll close if you press 'r' - closes the window (if you are like most people and don't want 'r' to close the window you can change it below.
* [t]o Deck page - t pulls up the current nations deck page
* [e]veryone hates useing 'e' to refresh a page rather then r - refreshes the current page
* [f]lip 9003 off because you are so thankful for his code, and I guess it flips the cards - flips the cards after opening a pack.
* [j]unks all cards listed below the default is to junk Uncommons, Rares, Ultra rares. You still need to press enter or space for the pop up - if you want to add commons to the junk list (IDK why you would :P) I have comment how to do that.
*/
A word of caution about junking it is super useful! Sometimes to useful it works on ANY page with cards that means your main deck page or OTHER PEOPLES deck page. Of course you can't junk other peoples cards but you might junk your own if you both own them.


Not so much a code in the first half but rather a puppet tracker!
Have you ever wondered hey who owns that weird puppet named Cardmania9003, well okay probs not that one its pretty clearly mine but what about
anglish? Well surprise surprise its me again! however wonder no more as I have started the puppet project!

You can sumbit your own puppets here

and view the entire sheet here

But 9003 I don't want to read several thousand puppets to find one person that's lame! Well I agree lucky thanks to Racoda you don't have to!
he has coded a lovely tamper monkey script (let me yahoo it for you if needed)

Once you have done that add another script and copy pasta this in

Code: Select all
// ==UserScript==
// @name         Main Auction Displayer
// @version      0.8
// @namespace    dithpri.RCES
// @description  Displays puppets' main nation above puppet name in an auction
// @author       dithpri
// @downloadURL  https://gist.github.com/dithpri/6a3fb524e59755510b18e676039b16d2/raw/main_auction_displayer.user.js
// @noframes
// @match        https://www.nationstates.net/*/page=deck/*
// @match        https://www.nationstates.net/page=deck/*
// @grant        GM.xmlHttpRequest
// @grant        GM.setValue
// @grant        GM.getValue
// @connect      docs.google.com
// ==/UserScript==


/* Permissions:
 *
 * GM.xmlHttpRequest, `connect docs.google.com`:
 *     to automatically fetch and update the puppet list.
 *
 * GM.setValue, GM.getValue:
 *     to save and load the puppet list locally.
 */

(async function() {
    'use strict';
    const canonicalize = function(name) {
        return name.trim().toLowerCase().replace(/ /g, "_");
    }

    const update_puppets = async function(isAuctionPage) {
        const puppets_map = JSON.parse(await GM.getValue("rces-main-nations", "{}"));
        if (isAuctionPage) {
            document.querySelectorAll("#cardauctiontable > tbody > tr > td > p > a.nlink, .deckcard-title > a.nlink:not(.rces-was-parsed)").forEach(function(el, i){
                const canonical_nname = el.getAttribute("href").replace(/^nation=/, "");
                el.classList.add("rces-was-parsed");
                if (Object.prototype.hasOwnProperty.call(puppets_map, canonical_nname)) {
                    const puppetmaster = puppets_map[canonical_nname];
                    el.insertAdjacentHTML('beforebegin',(`<a href="nation=${canonicalize(puppetmaster)}" class="nlink rces-was-parsed">(<span class="nnameblock">${puppetmaster}</span>)</a><br />`));
                }
            });
        }
        document.querySelectorAll("a.nlink:not(.rces-was-parsed)").forEach(function(el, i){
            const canonical_nname = el.getAttribute("href").replace(/^nation=/, "");
            if (Object.prototype.hasOwnProperty.call(puppets_map, canonical_nname)) {
                const puppetmaster = puppets_map[canonical_nname];
                el.classList.add("rces-was-parsed");
                el.insertAdjacentHTML('afterend',(`&nbsp;<a href="nation=${canonicalize(puppetmaster)}" class="nlink rces-was-parsed">(<span class="nnameblock">${puppetmaster}</span>)</a>`));
            }
        });
    };

    // If we haven't updated in the last 24h
    if ((await GM.getValue("rces-main-nations-lastupdate", 0)) + 24*60*60*1000 < (new Date().getTime())) {
        GM.xmlHttpRequest({
            method: "GET",
            url: "https://docs.google.com/spreadsheets/d/1MZ-4GLWAZDgB1TDvwtssEcVKHKunOKi3l90Jof1pBB4/export?format=tsv&id=1MZ-4GLWAZDgB1TDvwtssEcVKHKunOKi3l90Jof1pBB4&gid=733627866",
            onload: async function(data) {
                await GM.setValue("rces-main-nations",JSON.stringify(data.responseText
                                                               .split("\n")
                                                               .map((x) => x.split("\t").slice(0,1+1))
                                                               .slice(1)
                                                               .reduce(function(map, obj) {
                    map[canonicalize(obj[0].trim())] = obj[1].trim();
                    return map;
                }, {})));

                GM.setValue("rces-main-nations-lastupdate", new Date().getTime());
            }
        });
    }

    if (document.getElementById("auctiontablebox")) {
        update_puppets(true);
        let observer = new MutationObserver(function(mutationList) {
            update_puppets(true);
        });

        const observerOptions = {
            childList: true
        };

        observer.observe(document.getElementById("auctiontablebox"), observerOptions);
    } else {
        update_puppets(false);
    }
})();



For more tips and tricks like how to switch puppets like a boss join the discord I do demos every couple of weeks and help folks set up tools


[spoiler=The fine print that YOU SHOULD READ LIKE REALLY PLEASE READ THIS!]
This script does follow all of the scripting rules because it is 1:1 meaning that every action you do does one server side action. To junk cards you need to press j for each card. Holding the key down is a gray zone for legality so I can not stress enough please please please please please do not hold the keys down to spam through it. Spam pressing the keys is better anyway :P

if you would like to see more features shoot me a TG or post here and I can see what I can do.

The junking script is lose my design to work everywhere I am not responsible if it junks high value cards at any point be careful during pull events.
If you want to thank me and donate cards or whatever send them to 9006 but in all honesty I'd rather see you give them away to some farmer who needs it to complete a collection. This community of cards is driven by being generous. Go out and collect em all!
[/spoiler]
proud member of PETZ people for the Ethical Treatment of Zombies

Active member of The cards market place discord

User avatar
Racoda
Technical Moderator
 
Posts: 579
Founded: Aug 12, 2014
Democratic Socialists

Postby Racoda » Tue May 12, 2020 9:53 am

Thanks for including my script(s), but I've already posted the auction displayer a while ago: viewtopic.php?f=42&t=481816 (under Main Auction Displayer)

The thread includes screenshots as well as a direct link to install it and view the source code (clicking to install is far easier than having to copy-paste it).

It's not limited to Tampermonkey, you can use Greasemonkey as well.

In what concerns my script, please file bug reports in that thread and send tribute thank-you notes to Racoda.

EDIT 06/06/2020: FWIW, I've published the original keybinding script ("Card Hotkeys"), that I sent to 9003 in January, in my Github repository. Don't worry, I won't be suing 9003, just wanted to make sure it's properly published and that the line of authorship is clear.
Last edited by Racoda on Sat Jun 06, 2020 9:36 am, edited 4 times in total.

Acting as a player unless accompagnied by mod action or reddish text
Any pronouns

User avatar
Avrelis
Bureaucrat
 
Posts: 61
Founded: Feb 24, 2022
Iron Fist Consumerists

Postby Avrelis » Thu Mar 28, 2024 12:40 pm

so fauz is saying the junk thing is "illegal, and it needs human input" what happens if i use it (sorry for reply to old post, i couldnt find a definitive answer)
i was 98th most international artwork and I had triple spikes and math kangaroo, but then the outage happened... I was also gonna inflate Arlecchino…


Return to Trading Cards

Who is online

Users browsing this forum: A Share of the JPMorgan Chase

Advertisement

Remove ads