-
-
Save Sitethief/4a208eecadb2a09181d9dcf1ff2c1872 to your computer and use it in GitHub Desktop.
NSCollectionQueueAdd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name NSCollectionQueueAdd | |
// @namespace sitethiefs-ns-scripts | |
// @version 0.3 | |
// @description Keep pressing 'v' while using a card queue to loop trough all the cards that need to be put into a collection. It will ad them to the collection with `collectionID` | |
// @author Sitethief of Vylixan | |
// @match *://www.nationstates.net/page=deck/card=*/season=*/?manage_collections=* | |
// @match *://www.nationstates.net/page=deck/card=*/season=* | |
// @grant none | |
// @require https://craig.global.ssl.fastly.net/js/mousetrap/mousetrap.min.js?a4098 | |
// ==/UserScript== | |
/** | |
* Instructions: use the card query server to add cards | |
* Configure the collectionID variable | |
* Open the first card, and keep pressing v | |
**/ | |
/* | |
* Keybinds: | |
* [v] | |
*/ | |
(function() { | |
'use strict'; | |
function noinput_mousetrap(event) { | |
if (event.target.classList.contains("mousetrap")) { | |
event.preventDefault(); | |
event.stopPropagation(); | |
} | |
} | |
// this needs to be the collection ID you want to card to go to | |
let collectionID = '25399'; | |
let saveButton = document.querySelector("button.approve[name='save_collection']"); | |
Mousetrap.bind(['c'], function(ev) { | |
noinput_mousetrap(ev); | |
let allCheckboxes = document.querySelectorAll("#editcollectiontable2 > tbody > tr > td > p > input[type='checkbox']"); | |
console.log(allCheckboxes); | |
if (allCheckboxes.length && saveButton) { | |
allCheckboxes[0].click();+ | |
saveButton.click(); | |
} | |
}); | |
Mousetrap.bind(['v'], function(ev) { | |
noinput_mousetrap(ev); | |
if (!window.location.href.includes('manage_collections')) { | |
let infoBar = document.querySelector("p.info"); | |
if(infoBar) { | |
let nextButton = document.querySelector("#next_element_button"); | |
if (nextButton) { | |
nextButton.formAction = nextButton.formAction + '/template-overall=none/?manage_collections=1'; | |
console.log(nextButton); | |
nextButton.click(); | |
} | |
} else if (document.querySelectorAll("a.manage_collections_button").length){ | |
document.querySelectorAll("a.manage_collections_button")[0].click() | |
} | |
} else if(window.location.href.includes('manage_collections')) { | |
let checkboxes = document.querySelectorAll("#editcollectiontable2 > tbody > tr > td > p > input[type='checkbox'][name='selected_" + collectionID + "']"); | |
let infoBar = document.querySelector("p.info"); | |
let nextButton = document.querySelector("#next_element_button"); | |
if (infoBar && nextButton) { | |
nextButton.click(); | |
} else if (checkboxes.length && checkboxes[0].checked === false) { | |
checkboxes[0].click(); | |
saveButton.click(); | |
} else if(checkboxes.length && checkboxes[0].checked === true) { | |
// backup for when the save didn't fire | |
saveButton.click(); | |
} | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment