NATION

PASSWORD

[APPLICATION] nsalive-js

Bug reports, general help, ideas for improvements, and questions about how things are meant to work.
User avatar
RantSpot
Secretary
 
Posts: 36
Founded: Feb 15, 2010
New York Times Democracy

[APPLICATION] nsalive-js

Postby RantSpot » Thu Jul 20, 2017 10:01 am

nsalive-js is a Windows (WSH JScript) program to log in to a list of NationStates nations. It is similar to Ballotonia's Perl script, Auralia's web app and .NET Nation Manager and nslogin-cli for Node.js, and many, many others. But this one is mine. (I did not borrow/take/reuse code from any previous NS script.)

Why another login manager?
I wanted a simple Windows application which required no framework and no installation. I wanted it to be run from the command line and potentially be automated or scheduled.

Current Version: 0.1.1
Download Now(via Google Drive)

Features:
  • Logs in to NationStates.net with a sequence of nations
  • Uses HTTPS, provides User-Agent, and implements 0.6-second login delay (should comply with NationStates API rules)
  • Informs user of errors, including login (nation doesn't exist or has the wrong password) and network/connectivity issues
  • Takes headerless CSV of nations and passwords as input; further usage instructions in readme file
Future development:
  • Task Scheduler file/installer
  • Differentiate between CTE (revivable), CTE (gone), and never existed
  • Store passwords as encrypted autologin token
  • Catch more errors
Changelog:
  • 0.1: initial release
  • 0.1.1: code style cleanup, moved to API, error response handling
License: Modified MIT License

Copyright (c) 2017 RantSpot (pseudonym)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software. The author of this software
shall be credited in any derivative work.


THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Additional disclaimer:
I cannot guarantee how this will be interpreted by NationStates admins. The delay used by this program assumes that no other scripts are logging into the nations; use of multiple scripts may violate exceed the limits set forth in the API rules.
Last edited by RantSpot on Sun Jul 23, 2017 5:29 pm, edited 2 times in total.

User avatar
[violet]
Executive Director
 
Posts: 16207
Founded: Antiquity

Postby [violet] » Thu Jul 20, 2017 3:10 pm

While this is fine, just FYI it would be better to implement via an API Nation Private Shard like "ping". You don't need to change much, just the part of the site you're contacting. Benefits:

- faster

- no 6-second delay required

- no possibility of accidentally falling afoul of rules like the one barring simultaneous requests

- no HTML parsing required

- returns easily parseable error codes so you know if anything went wrong

- you don't have to worry that the HTML will change on the login page and break your script

- scripts may be banned from interacting with the HTML site in the future
Last edited by [violet] on Thu Jul 20, 2017 3:12 pm, edited 2 times in total.

User avatar
RantSpot
Secretary
 
Posts: 36
Founded: Feb 15, 2010
New York Times Democracy

Postby RantSpot » Thu Jul 20, 2017 5:54 pm

Switched to API, working smoothly. Definitely faster, especially without the 6-second delay. I'll post the update shortly.

Is there any way to differentiate between nations which CTEd and can be restored, nations which CTEd and can't be restored, and nations that don't exist? They all return 404 statuses, the same headers, and no XML. I could scrape the boneyard but that seems a bit kludge-y.

Is there any way to log out after a request? Is there any need to do so?
Last edited by RantSpot on Thu Jul 20, 2017 5:56 pm, edited 1 time in total.

User avatar
Shizensky
Diplomat
 
Posts: 602
Founded: Mar 29, 2004
New York Times Democracy

Postby Shizensky » Thu Jul 20, 2017 6:10 pm

[violet] wrote:- scripts may be banned from interacting with the HTML site in the future

Is this specifically for those scripts that scrape the HTML or do you mean for it to extend to browser extensions?
"Look, that's why there's rules, understand?
So that you think before you break 'em."
My favorite thing about UDP jokes
is I don't care if you get them or not.

User avatar
[violet]
Executive Director
 
Posts: 16207
Founded: Antiquity

Postby [violet] » Thu Jul 20, 2017 9:38 pm

RantSpot wrote:Is there any way to differentiate between nations which CTEd and can be restored, nations which CTEd and can't be restored, and nations that don't exist?

Not at the moment, but feel free to request it in the API thread stickied in this forum. It wouldn't be too hard to send a different signal for CTE nations vs never-been-any-such nations.

RantSpot wrote:Is there any way to log out after a request? Is there any need to do so?

No.

Shizensky wrote:
[violet] wrote:- scripts may be banned from interacting with the HTML site in the future

Is this specifically for those scripts that scrape the HTML or do you mean for it to extend to browser extensions?

There's no plan to do anything at the moment. It's just an admin desire to shift legitimate bots to the API so that illegitimate ones are easier to spot.

User avatar
Caelapes
Ambassador
 
Posts: 1543
Founded: Apr 30, 2007
Ex-Nation

Postby Caelapes » Fri Jul 21, 2017 8:24 am

[violet] wrote:
RantSpot wrote:Is there any way to differentiate between nations which CTEd and can be restored, nations which CTEd and can't be restored, and nations that don't exist?

Not at the moment, but feel free to request it in the API thread stickied in this forum. It wouldn't be too hard to send a different signal for CTE nations vs never-been-any-such nations.

What about "CTE-from-inactivity" vs. "CTE-from-modbombing"?
    
The Rose Commune of Caelapes
Ego vero custos fratris mei sum.
aka Misley

User avatar
RantSpot
Secretary
 
Posts: 36
Founded: Feb 15, 2010
New York Times Democracy

Postby RantSpot » Sun Jul 23, 2017 5:30 pm

I have uploaded the updated API script. It also has a bunch of error catching, which did not exist in the first version.

User avatar
Auralia
Senator
 
Posts: 4982
Founded: Dec 15, 2011
Ex-Nation

Postby Auralia » Tue Jul 25, 2017 1:15 pm

[violet] wrote:
Shizensky wrote:Is this specifically for those scripts that scrape the HTML or do you mean for it to extend to browser extensions?

There's no plan to do anything at the moment. It's just an admin desire to shift legitimate bots to the API so that illegitimate ones are easier to spot.

My login script still interacts with the website directly -- which is a real pain to do in JS in a web browser, incidentally, thanks to the same-origin policy -- because AFAIK you can't use the API to restore CTE'd nations. This is presumably because it's an action that would cause a change in a sinker's regional happenings, making it subject to the "one-click-per-action" rule.
Catholic Commonwealth of Auralia
"Amor sequitur cognitionem."

User avatar
RantSpot
Secretary
 
Posts: 36
Founded: Feb 15, 2010
New York Times Democracy

Postby RantSpot » Tue Jul 25, 2017 1:40 pm

Auralia wrote:My login script still interacts with the website directly -- which is a real pain to do in JS in a web browser, incidentally, thanks to the same-origin policy -- because AFAIK you can't use the API to restore CTE'd nations.

I requested in the API thread that data on boneyard/CTEs be made available through the API, perhaps public shards. That's not refounding but it's a step in the right direction. The more the API can do, the less calls would need to be made to the site. (Though I suspect there won't be an option to refound through the API ever for the reason you cite and others, much as I doubt there will be an option to found nations en masse via API)


Advertisement

Remove ads

Return to Technical

Who is online

Users browsing this forum: Minoa, Tamocordia

Advertisement

Remove ads