MZ Critical damage gives an extra turn

Is there any plugin that makes it so that when a character (or enemy) deals critical damage, he gains an extra turn?
If you're using the built-in TPB battle system, you can try this:
Spoiler: plugin code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Landing a crit refills the subject's TPB gauge.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/index.php?threads/153960/
 * @help Free to use and/or modify for any project, no credit required.
 */
void (() => {
'use strict';
  let extraTurn = false;
  void (alias => {
    Game_Action.prototype.apply = function(target) {
      alias.apply(this, arguments);
      extraTurn ||= target.result().critical;
    };
  })(Game_Action.prototype.apply);
  void (alias => {
    BattleManager.endBattlerActions = function(battler) {
      alias.apply(this, arguments);
      if (extraTurn)
        battler.initTpbChargeTime(true);
      extraTurn = false;
    };
  })(BattleManager.endBattlerActions);
})();
[Edit: changed extraTurn = target.result().critical to extraTurn ||= etc, so it checks for any crit in the battler's actions, rather than only the most recent target/apply.]
If you're using the built-in TPB battle system, you can try this:
Spoiler: plugin code
JavaScript:
/*:
 * @target MZ
 * @plugindesc Landing a crit refills the subject's TPB gauge.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/index.php?threads/153960/
 * @help Free to use and/or modify for any project, no credit required.
 */
void (() => {
'use strict';
  let extraTurn = false;
  void (alias => {
    Game_Action.prototype.apply = function(target) {
      alias.apply(this, arguments);
      extraTurn = target.result().critical;
    };
  })(Game_Action.prototype.apply);
  void (alias => {
    BattleManager.endBattlerActions = function(battler) {
      alias.apply(this, arguments);
      if (extraTurn)
        battler.initTpbChargeTime(true);
      extraTurn = false;
    };
  })(BattleManager.endBattlerActions);
})();
Thanks!
Ok, I managed to modify the plugin with the help of some friends.
Player now gets 1 extra turn per round instead of getting infinite extra turns.
Super effective elemental strikes also give an extra turn.
Each time the player gains an extra turn, an SE is played.

(Sorry for bad grammar, my English is pretty bad)

Original thread: https://forums.rpgmakerweb.com/threads/critical-damage-gives-an-extra-turn.153960/