Automatically update note's properties

I want to update note properties when an event happens.

For example, I want to track how many times I’ve modified a note over the last year, month, or week (counted daily). So, I need to set and update ‘mcounter’ and ‘mdates’ properties each time I make a change.

How can I accomplish it in Obsidian?

I can write simple JS code. I don’t know how to access Obsidian data and execute the code when I would like it to run.

I tried Dataview, Templatr and QuickAdd plugins. They cover a lot of my use cases. But, unless I miss sth, they won’t work in the case specified above.

Thank you in advance for any help.