Leave a Reply

jQuery(document).ready(function($) { $('article.post img').each(function() { var imageSrc = $(this).attr('src'); // Extract the image filename and extension from the URL var imageFilename = imageSrc.split('/').pop(); // Create a download link using the original image URL and filename var downloadLink = 'Download Image'; $(this).after(downloadLink); }); $(".download-button").on("click", function(e){ e.preventDefault(); var downloadLink = $(this).attr("href"); var counter = 25; // Changed the timer to 25 seconds var button = $(this); var interval = setInterval(function(){ if (counter <= 0) { clearInterval(interval); var anchor = document.createElement('a'); anchor.href = downloadLink; // Set the filename from the download link var filename = button.attr('download'); anchor.download = filename; anchor.click(); button.text('Download Image'); // Reset button text after download button.off("click"); // Remove the click event listener button.on("click", function(e){ e.preventDefault(); var downloadLink = $(this).attr("href"); var counter = 25; // Changed the timer to 25 seconds var button = $(this); var interval = setInterval(function(){ if (counter <= 0) { clearInterval(interval); var anchor = document.createElement('a'); anchor.href = downloadLink; // Set the filename from the download link var filename = button.attr('download'); anchor.download = filename; anchor.click(); button.text('Download Image'); // Reset button text after download } else { button.text('Please Wait ' + counter + 's'); counter--; } }, 1000); }); } else { button.text('Please Wait ' + counter + 's'); counter--; } }, 1000); }); }); document.addEventListener('contextmenu', function(e) { if (e.target.tagName === 'IMG') { e.preventDefault(); } });