Update current WP post every 3 minutes [closed]

Classic Editor:

autosave.js file

setInterval(function () {document.getElementById("publish").click()}, 300000);

php function

// Load js file on specific post type in class editor
function load_js_file_classic_editor( $hook ) {

    global $post;

    if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
        if ( 'post' === $post->post_type ) {     
            wp_enqueue_script(  'myautosave', get_stylesheet_directory_uri().'/includes/js/autosave.js' );
        }
    }
}
add_action( 'admin_enqueue_scripts', 'load_js_file_classic_editor', 10, 1 );

Gutenberg

setInterval(function() {
    wp.data.dispatch( 'core/editor' ).savePost();
}, 60 * 1000); // 60 * 1000 milsec