Hide Delete and Edit button on LEead CRM Note Screen

Hi All I want to Hide the Delete & Edit button in Lead, CRM Note Screen.
With Below Code, I am able to Hide it When the form is loaded, but whenever I add or remove any Note, the button shows up again

frappe.ui.form.on('Lead', {
    onload: function(frm) {
        // Initial hiding of buttons
        hide_note_buttons(frm);

        // Ensure buttons are hidden when notes are refreshed
        frm.fields_dict.notes.grid.wrapper.on('click', '.grid-add-row, .grid-remove-rows', function() {
            setTimeout(() => {
                hide_note_buttons(frm);
            }, 500);
        });
    },
    refresh: function(frm) {
        // Hide buttons on refresh
        setTimeout(() => {
            hide_note_buttons(frm);
        }, 500);
    }
});

function hide_note_buttons(frm) {
    // Get the current user
    var current_user = frappe.session.user;

    // Iterate through the notes and hide buttons for non-owners
    $('.comment-content').each(function() {
        var added_by = $(this).find('.head .title').text().trim();
        if (added_by !== current_user) {
            // Hide the edit button
            $(this).find('.edit-note-btn').hide();

            // Hide the delete button
            $(this).find('.delete-note-btn').hide();
        }
    });

    // Hide the "Done" button in modal forms
    $('.standard-actions .btn-modal-primary').each(function() {
        var buttonText = $(this).text().trim();
        if (buttonText === 'Done') {
            $(this).hide();
        }
    });
}

Help me implement this functionality, A New approach is also welcome.

Thanks in advance

Which edit and delete buttons are you talking about?

Share the screenshot.


This Part, 2nd last Tab of Lead Form

Try it.

frappe.ui.form.on('Lead', {
    onload_post_render: function(frm) {
        $('.col-xs-1.text-right').hide();
    },
    refresh: function(frm) {
        $('.col-xs-1.text-right').hide();
    }
});

I tried

Yes, button gets hide when it loads first time
But again happens the below issue

Buttons are back after new Note was added

Also, I want to hide the buttons for the notes, which is not created by that user.

When adding a new note, it appears but then hides after 2 seconds. Please check it again. It worked on my end. If it doesn’t work, you may need to apply the logic with a timer.

Got it,
Now I have only add the condition for check if note is created by the users or not, if not then hide the button
Thank you