Creating this in order not to forget the suggestion given at
https://gerrit.wikimedia.org/r/#/c/49609/
Martineznovo 08:16
Patch Set 5:
(...) it could be improved using the mediawiki.api.watch ResourceLoader module that implements all the logic and tokens usage, without the need to replicate it here.
https://www.mediawiki.org/wiki/RL/DM#mediawiki.api.watch
Version: unspecified
Severity: enhancement