1
0
Fork 0

main.user.js aktualisiert
Some checks failed
QS / QS (push) Failing after 4s

This commit is contained in:
Snoweuph 2024-07-28 09:47:06 +00:00
parent c83b3635a3
commit 2ed3dddf8b

View file

@ -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(