<script>

var observer;
var actionTimeout;

var hasExecuted = false;


function executeActions() {

    // Check if the function has already run
    if (hasExecuted) {
        return; // Exit the function if it has already run
    }

    hasExecuted = true; // Set the flag to true to prevent future executions

    // Click the specified element
    document.querySelector('#wcdp-canvas-thumbs-container > div:nth-child(2)').click();

// Retrieve the URL from localStorage
var primarySiteUrl = localStorage.getItem('primarySiteUrl');

if (primarySiteUrl) {
    // Set the value of the input field to the retrieved URL
    document.querySelector('#wcdp-text-box-qr').value = primarySiteUrl;


    // Trigger the click or AJAX event on the button
    document.querySelector('#wcdp-btn-make-qr').click();

// Select the elements
var btnQr = document.querySelector('span#wcdp-btn-qr');
var qrCodePanel = document.querySelector('#wcdp-qrcode-panel');

// Set display to none with !important
if (btnQr) {
    btnQr.style.setProperty('display', 'none', 'important');
}

if (qrCodePanel) {
    qrCodePanel.style.setProperty('display', 'none', 'important');
}


	
// Select elements
var postContentElement = document.querySelector('#wcdp-container');
var toolbarOptionsElement = document.querySelector('div#wcdp-toolbar-options');
var optsBelowCanvasElement = document.querySelector('div#wcdp-opts-below-canvas');

var ldsDualRing = document.querySelector('.lds-dual-ring');
	
	if (ldsDualRing) {
    ldsDualRing.style.setProperty('display', 'none', 'important');
}

// Function to set visibility to visible with !important
function setVisible(element) {
    if (element) {
        element.style.setProperty('visibility', 'visible', 'important');
    }
}
	


// Change the visibility property to 'visible' for each element
setVisible(postContentElement);
setVisible(toolbarOptionsElement);
setVisible(optsBelowCanvasElement);


// Select the 'Front' div, which is the first child of '#wcdp-canvas-thumbs-container'
var frontDiv = document.querySelector('#wcdp-canvas-thumbs-container > div[data-id="front"]');

// Function to ignore click events
function disableClick(event) {
    event.preventDefault();
    event.stopPropagation();
}

// Attach the event listener to the 'Front' div and change cursor style
if (frontDiv) {
    frontDiv.addEventListener('click', disableClick, true);
    frontDiv.style.cursor = 'default';  // or 'none' if you want to hide the cursor entirely
}

} else {
    // Log an error message to the console if the localStorage item is not set
    console.log('Error: Primary site URL is not set in localStorage.');
}



}

function startObserving() {
    observer = new MutationObserver(function(mutations) {
        // Reset the timer each time there's a change in the DOM
        clearTimeout(actionTimeout);
        actionTimeout = setTimeout(executeActions, 3000); // Wait for 3 seconds
    });

    observer.observe(document.body, {
        childList: true,
        subtree: true,
        attributes: true,
        characterData: true
    });
}

startObserving();

	
	
</script>