Skip to content

Commit 4eb4e32

Browse files
committed
Create Index.html
1 parent 5a29764 commit 4eb4e32

File tree

1 file changed

+126
-0
lines changed

1 file changed

+126
-0
lines changed

Index.html

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Arma 3 Mod ID Extractor</title>
7+
<style>
8+
body {
9+
font-family: Arial, sans-serif;
10+
margin: 20px;
11+
}
12+
textarea {
13+
width: 100%;
14+
height: 150px;
15+
margin-bottom: 10px;
16+
}
17+
.hidden {
18+
display: none;
19+
}
20+
</style>
21+
</head>
22+
<body>
23+
<h1>Arma 3 Mod ID Extractor</h1>
24+
25+
<label for="fileInput">Load .html File:</label>
26+
<input type="file" id="fileInput" accept=".html">
27+
28+
<h3>Options:</h3>
29+
<input type="checkbox" id="includeAt" onclick="updateOutput()"> Include '@' before each entry<br>
30+
<input type="checkbox" id="showNames" checked onclick="updateOutput()"> Show Names (instead of only IDs)<br>
31+
32+
<h3>Output Format:</h3>
33+
<input type="radio" name="format" value="newline" checked onclick="updateOutput()"> Newline<br>
34+
<input type="radio" name="format" value="semicolon" onclick="updateOutput()"> Semicolon<br>
35+
<input type="radio" name="format" value="comma" onclick="updateOutput()"> Comma<br>
36+
37+
<h3>Extracted Output:</h3>
38+
<textarea id="output" readonly>Output will appear here...</textarea>
39+
40+
<h3>Sanitized Mods:</h3>
41+
<textarea id="sanitizedMods" readonly>No mods required sanitization.</textarea>
42+
43+
<button onclick="downloadOutput()">Save List</button>
44+
45+
<script>
46+
let extractedData = [];
47+
let sanitizedMods = [];
48+
49+
document.getElementById('fileInput').addEventListener('change', function(event) {
50+
const file = event.target.files[0];
51+
if (file) {
52+
const reader = new FileReader();
53+
reader.onload = function(e) {
54+
processFile(e.target.result);
55+
};
56+
reader.readAsText(file);
57+
}
58+
});
59+
60+
function sanitizeFilename(name) {
61+
const invalidChars = /[<>:"/\\|?*]/g;
62+
const unescapedName = name.replace(/&amp;/g, '&');
63+
return unescapedName.replace(invalidChars, '_');
64+
}
65+
66+
function processFile(content) {
67+
extractedData = [];
68+
sanitizedMods = [];
69+
const lines = content.split('\n');
70+
let displayName = '';
71+
72+
lines.forEach(line => {
73+
if (line.includes('data-type="DisplayName"')) {
74+
displayName = line.split('>')[1].split('<')[0];
75+
}
76+
if (line.includes('?id=')) {
77+
const id = line.match(/\?id=(\d+)/)[1];
78+
const sanitizedName = sanitizeFilename(displayName);
79+
if (sanitizedName !== displayName && !displayName.includes('&')) {
80+
sanitizedMods.push(`Original: ${displayName}\nSanitized: ${sanitizedName}`);
81+
}
82+
extractedData.push({ name: sanitizedName, id });
83+
}
84+
});
85+
86+
updateOutput();
87+
updateSanitizedMods();
88+
}
89+
90+
function updateOutput() {
91+
const includeAt = document.getElementById('includeAt').checked;
92+
const showNames = document.getElementById('showNames').checked;
93+
const format = document.querySelector('input[name="format"]:checked').value;
94+
95+
let output = extractedData.map(entry => {
96+
let value = showNames ? entry.name : entry.id;
97+
return includeAt ? `@${value}` : value;
98+
});
99+
100+
if (format === 'semicolon') {
101+
output = output.join(';');
102+
} else if (format === 'comma') {
103+
output = output.join(',');
104+
} else {
105+
output = output.join('\n');
106+
}
107+
108+
document.getElementById('output').value = output;
109+
}
110+
111+
function updateSanitizedMods() {
112+
const sanitizedModsText = sanitizedMods.length ? sanitizedMods.join('\n\n') : "No mods required sanitization.";
113+
document.getElementById('sanitizedMods').value = sanitizedModsText;
114+
}
115+
116+
function downloadOutput() {
117+
const output = document.getElementById('output').value;
118+
const blob = new Blob([output], { type: 'text/plain' });
119+
const link = document.createElement('a');
120+
link.href = URL.createObjectURL(blob);
121+
link.download = 'mod_list.txt';
122+
link.click();
123+
}
124+
</script>
125+
</body>
126+
</html>

0 commit comments

Comments
 (0)