Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -189,23 +189,22 @@ <h1>Wispcraft Injector</h1>
const htmlFile = fileElem.files[0];
const reader = new FileReader();
reader.onload = function (e) {
let content = e.target.result;
let index = content.toLowerCase().indexOf("<head>");
if (index == -1) {
const content = e.target.result;
const parser = new DOMParser();
const doc = parser.parseFromString(content, "text/html");
if (!doc.head) {
alert("Invalid client file!");
fileElem.value = "";
fileElem.removeAttribute("disabled");
return;
}
index += 6;

let inject = `
<script type="text/javascript">
${atob(getWispcraftBundle())}
<${"/"}script>
`;
content = content.slice(0, index) + inject + content.slice(index);
const blob = new Blob([content], {
const script = doc.createElement("script");
script.type = "text/javascript";
script.textContent = atob(getWispcraftBundle());
doc.head.appendChild(script);
const serializer = new XMLSerializer();
const finalContent = serializer.serializeToString(doc);
const blob = new Blob([finalContent], {
type: "text/html; charset=utf-8",
});
downloadLink.download = "wispcraft-" + htmlFile.name;
Expand Down