jQuery(document).ready(function($) { // Find the SKU label and input const skuLabel = $('label[for="aps-sku"]'); const skuInput = $('#aps-sku'); // Add click handler to the SKU label skuLabel.on('click', function(e) { e.preventDefault(); // Get current URL const urlParams = new URLSearchParams(window.location.search); const postId = urlParams.get('post'); if (postId) { // Set the value in the input field skuInput.val(postId); // Optional: Add visual feedback skuInput.css('background-color', '#e8f0fe') .delay(200) .queue(function(next) { $(this).css('background-color', ''); next(); }); // Optional: Copy to clipboard navigator.clipboard.writeText(postId).then( function() { // Success feedback console.log('Post ID copied to clipboard'); // Create and show a temporary success message const message = $('
') .text('Post ID copied!') .css({ position: 'fixed', top: '50%', left: '50%', transform: 'translate(-50%, -50%)', padding: '10px 20px', backgroundColor: '#4CAF50', color: 'white', borderRadius: '4px', zIndex: 9999 }) .appendTo('body'); // Remove the message after 2 seconds setTimeout(function() { message.fadeOut(function() { $(this).remove(); }); }, 2000); }, function(err) { console.error('Could not copy ID:', err); } ); } }); });