Hello!
I'm new here, I'm trying to block large image because the 9hits application doesn't support external extensions.
This is the code I am trying to run:
But still the image are still loading when I tried it with Macro Editor,
Also please let me know if you have better idea..
TIA
I'm new here, I'm trying to block large image because the 9hits application doesn't support external extensions.
This is the code I am trying to run:
Code:
Javascript:
function blockLargeImageURLs() {
const maxImageSizeBytes = 2.5 * 1024 * 1024; // 2.5MB in bytes
document.querySelectorAll('img').forEach(img => {
const src = img.getAttribute('src');
const fileExtensionRegex = /\.\w{3,4}$/;
if (fileExtensionRegex.test(src)) {
const fileExtension = src.match(fileExtensionRegex)[0].toLowerCase();
const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp', '.svg', '.tiff'];
if (imageExtensions.includes(fileExtension)) {
const estimatedSizeKB = 1000; // Adjust this value as needed
if (estimatedSizeKB > maxImageSizeBytes / 1024) {
img.style.display = 'none'; // Hide the image
console.log(`Blocked image "${src}" because its estimated URL size exceeds 2.5MB.`);
}
}
}
});
}
blockLargeImageURLs();
Also please let me know if you have better idea..
TIA