From 2ed3dddf8b1f07642a6519b740093e55c0d62255 Mon Sep 17 00:00:00 2001 From: Snoweuph Date: Sun, 28 Jul 2024 09:47:06 +0000 Subject: [PATCH] main.user.js aktualisiert --- main.user.js | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/main.user.js b/main.user.js index 8179399..c4ef395 100644 --- a/main.user.js +++ b/main.user.js @@ -3,7 +3,7 @@ // @namespace https://git.euph.dev/Snoweuph // @match https://army-forge.onepagerules.com/view* // @grant none -// @version 1.0.3 +// @version 1.0.4 // @author Snoweuph // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js // @require https://html2canvas.hertzen.com/dist/html2canvas.min.js @@ -25,13 +25,17 @@ function generateCards() { Array.from(cards_root.children).forEach((child) => { const card = child.firstElementChild; const header = card.firstElementChild; + const title = getHeaderTitle(header) + const unit_count = getUnitCount(title) const marker_section = document.createElement("div"); - marker_section.style.display = "flex"; + marker_section.style.display = "grid"; + marker_section.style.gridTemplateColumns = "repeat(10, 1fr)"; marker_section.style.gap = "0.5rem"; marker_section.style.padding = "0.5rem"; marker_section.style.marginBottom = "0.5rem"; - for (let i = 0; i < 10; i++) { + + for (let i = 0; i < 10 * unit_count; i++) { const maker_space = document.createElement("div"); maker_space.style.width = "3rem"; maker_space.style.aspectRatio = "1"; @@ -43,7 +47,7 @@ function generateCards() { html2canvas(card, { scale: 15, backgroundColor: null }).then((canvas) => { const link = document.createElement("a"); - link.download = getHeaderTitle(header) + ".png"; + link.download = + ".png"; link.href = canvas.toDataURL(); document.body.appendChild(link); link.click(); @@ -78,8 +82,11 @@ function generateRules() { }); } +function getUnitCount(str) { + const match = str.match(/^\d+/); + return match ? parseInt(match[0], 10) : 1; +} -// Extract Title of Card function getHeaderTitle(pElement) { let textContent = ""; pElement.firstElementChild.firstElementChild.firstElementChild.childNodes.forEach(