commit
48eb1b040a
5 changed files with 107 additions and 0 deletions
18
.gitea/workflows/qs.yml
Normal file
18
.gitea/workflows/qs.yml
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
name: "QS"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
qs:
|
||||||
|
name: "QS"
|
||||||
|
runs-on: "ubuntu-latest"
|
||||||
|
container:
|
||||||
|
image: "git.euph.dev/actions/runner-js-latest:latest"
|
||||||
|
steps:
|
||||||
|
- name: "Checkout"
|
||||||
|
uses: "https://git.euph.dev/actions/checkout@v3"
|
||||||
|
- name: "Prettier"
|
||||||
|
run: npm_config_yes=true npx prettier src/ types/ --check --log-level=error
|
7
Readme.md
Normal file
7
Readme.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
# CCNA Autofill UserScript
|
||||||
|
Simple Userscript to Create Tabletop Cards from Armyforge Cards
|
||||||
|
|
||||||
|
[![Install USerscript](https://img.shields.io/badge/Install_Userscript-Install_Userscript?style=for-the-badge&logo=greasyfork&logoColor=black&color=brown)](https://git.euph.dev/Snoweuph/Armyfroge_Cards_Userscript/raw/branch/main/main.user.js)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
Press `CTRL` + `s` to Save the Current Cards.
|
8
jsconfig.json
Normal file
8
jsconfig.json
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"checkJs": true,
|
||||||
|
"target": "es6",
|
||||||
|
"lib": ["dom", "es6"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
64
main.user.js
Normal file
64
main.user.js
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
// ==UserScript==
|
||||||
|
// @name Armyfroge Cards
|
||||||
|
// @namespace https://git.euph.dev/Snoweuph
|
||||||
|
// @match https://army-forge.onepagerules.com/view*
|
||||||
|
// @grant none
|
||||||
|
// @version 1.0.0
|
||||||
|
// @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
|
||||||
|
// ==/UserScript==
|
||||||
|
|
||||||
|
// Bind to Ctrl + S
|
||||||
|
document.addEventListener("keydown", (event) => {
|
||||||
|
if (event.ctrlKey && event.key === "s") {
|
||||||
|
event.preventDefault();
|
||||||
|
generate();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function generate() {
|
||||||
|
const cards_root =
|
||||||
|
document.getElementsByClassName("MuiContainer-root")[0].firstElementChild;
|
||||||
|
|
||||||
|
Array.from(cards_root.children).forEach((child) => {
|
||||||
|
const card = child.firstElementChild;
|
||||||
|
const header = card.firstElementChild;
|
||||||
|
|
||||||
|
const marker_section = document.createElement("div");
|
||||||
|
marker_section.style.display = "flex";
|
||||||
|
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++) {
|
||||||
|
const maker_space = document.createElement("div");
|
||||||
|
maker_space.style.width = "3rem";
|
||||||
|
maker_space.style.aspectRatio = "1";
|
||||||
|
maker_space.style.borderRadius = "100%";
|
||||||
|
maker_space.style.border = "dashed 1px lightgray";
|
||||||
|
marker_section.appendChild(maker_space);
|
||||||
|
}
|
||||||
|
card.insertBefore(marker_section, header.nextSibling);
|
||||||
|
|
||||||
|
html2canvas(card, { scale: 15, backgroundColor: null }).then((canvas) => {
|
||||||
|
const link = document.createElement("a");
|
||||||
|
link.download = getHeaderTitle(header) + ".png";
|
||||||
|
link.href = canvas.toDataURL();
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract Title of Card
|
||||||
|
function getHeaderTitle(pElement) {
|
||||||
|
let textContent = "";
|
||||||
|
pElement.firstElementChild.firstElementChild.firstElementChild.childNodes.forEach(
|
||||||
|
(node) => {
|
||||||
|
if (node.nodeType === Node.TEXT_NODE) {
|
||||||
|
textContent += node.textContent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return textContent;
|
||||||
|
}
|
10
prettierrc.json
Normal file
10
prettierrc.json
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"useTabs": false,
|
||||||
|
"tabWidth": 4,
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"bracketSameLine": false,
|
||||||
|
"singleQuote": true,
|
||||||
|
"semi": true,
|
||||||
|
"trailingComma": "none",
|
||||||
|
"endOfLine": "lf"
|
||||||
|
}
|
Loading…
Reference in a new issue