Modifying Google Drive Interface for File Deletion Controls

I’m managing our company’s G Suite environment and need to implement a feature where team members must add comments before removing files from shared drives.

After doing some research, it looks like creating a Chrome extension with content scripts is the way to modify the shared drive interface. However, I’m running into issues with the current Google Drive implementation.

The problem is that Google Drive now uses HTML5 and I can’t seem to identify the specific HTML element for the remove button. This makes it impossible to trigger my custom script when users try to delete files.

Here’s my current approach that triggers on all div clicks:

$('div').on('click', function(){
    console.log($(this).attr('data-tooltip'));
    if($(this).hasClass('custom-delete-btn active-state'))
    {
        console.log('Delete action detected');
    }       
});

Does anyone have experience with this kind of Google Drive customization? Are there better approaches to enforce comment requirements before file deletion in team drives?

I’ve been down this road and learned the hard way - don’t target Google Drive’s UI elements directly. Their class names and data attributes change constantly with updates, so you’ll be constantly fixing broken code. Skip the delete button interception entirely. Use Google Apps Script with Drive API event triggers instead. Set up onEdit or onChange triggers that catch deletion attempts and force users through a custom dialog for comments before the delete goes through. This works at the API level instead of fighting with the interface, so it’s way more reliable. Yeah, users have to use your custom interface for deletions, but honestly that gives you better audit trails for compliance anyway.

hooking into google drive’s interface is a nightmare - they constantly change their DOM structure. check out google workspace admin controls instead. there might be native permission settings that require approval before deletions, which beats dealing with chrome extensions that break every update.

Had the same requirements at my old job - totally get the frustration. Google Drive’s interface changes constantly, so DOM manipulation breaks all the time. Here’s a different approach: forget trying to block deletions and focus on accountability instead. Set up Google Workspace audit logs to track file deletions, then use Google Apps Script to scan the logs daily. When someone deletes files, automatically email them asking for justification. Make it required - escalate to management if they don’t respond. It’s not prevention, but it creates accountability and stops people from casually deleting stuff. Works way better than technical barriers since users can’t bypass it and you’re not constantly fixing broken code every time Google updates their UI.