-
-
Save Sitethief/d7c67ef9d89455af46b13de8c373c895 to your computer and use it in GitHub Desktop.
Nationstates Card Preview
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 NSCardPreview | |
// @namespace sitethiefs-ns-scripts | |
// @version 0.4 | |
// @description Previews your current flag on all cards on the page | |
// @author Sitethief of Vylixan | |
// @match *www.nationstates.net/*page=deck* | |
// @grant none | |
// ==/UserScript== | |
/** | |
* Instructions: Go to any page with cards on it, click the preview button in the menu bar to see how your card looks. Only tested in default theme. | |
* To go back to how it should look simply refresh the page | |
* | |
* Optionally, if you set the hideTitles option to true it will also hide titles that might cover part of the flag on Season 2 cards | |
* Optionally, if you set the hideSmallBits option to true it will also the two small inserts in the bottom corners of Season two cards. | |
* | |
* Note: this is not in any way, shape or form a real preview of any card or season desing in Nationstates, it simply replaces all card flags on the current page with your current flag. | |
* Tip: use a page with both season 1 and season 2 cards, try out different rarities, the background color and/or border color does matter, especially with transparant cards | |
* For example this collection: https://www.nationstates.net/page=deck/collection=31424 | |
**/ | |
(function() { | |
'use strict'; | |
const hideTitles = false; | |
const hideSmallBits = false; | |
var preview_button_top; | |
if(!preview_button_top) { | |
preview_button_top = document.createElement("div"); | |
preview_button_top.setAttribute('class',"bel"); | |
preview_button_top.innerHTML = "<div class=\"belcontent\"><a href=\"#\" class=\"bellink\"><i class=\"icon-cards\"></i>CARDS</a><div class=\"notificationnumber refreshable\" style=\"background-color:red\">Preview</div></div>"; | |
preview_button_top.addEventListener("click",previewCard,false); | |
} | |
(document.getElementsByClassName("belspacer belspacermain")[0]).before(preview_button_top); | |
function previewCard(event) { | |
event.preventDefault(); | |
let flags = document.querySelectorAll('div.deckcard-flag'); | |
const newImage = document.querySelector('div.bannernation'); | |
if (flags.length) { | |
for(let flag of flags) { | |
flag.style.backgroundImage = newImage.style.backgroundImage; | |
} | |
} | |
if (hideTitles) { | |
let titles = document.querySelectorAll('div.deckcard-season-2 > figure.front > div.deckcard-title'); | |
if (titles.length) { | |
for(let title of titles) { | |
title.style.visibility = 'hidden'; | |
} | |
} | |
} | |
if (hideSmallBits) { | |
let bits = document.querySelectorAll('div.deckcard-season-2 > figure.front > div.deckcard-lower > div.deckcard-desc > span.deckcard-desc-bit'); | |
if (bits.length) { | |
for(let bit of bits) { | |
bit.style.visibility = 'hidden'; | |
} | |
} | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment