Detecting changes in Google Docs using scripts

I’ve been working with Google Docs automation for a while, and you’re right - there’s no direct equivalent to the onEdit trigger for Docs. However, I’ve found a workaround that might help. You can use time-based triggers to run a script at regular intervals. In your script, you can compare the current state of the document to a previously saved state to detect changes.

Here’s a rough outline of the approach:

  1. Save the document’s content as a property
  2. Set up a time-based trigger to run every few minutes
  3. In the triggered function, compare the current content to the saved content
  4. If there’s a difference, run your desired actions and update the saved content

It’s not real-time, but it’s the closest I’ve found to achieving what you’re after. Just be mindful of quotas and performance if you’re dealing with large documents or frequent updates.