How to inject code into node body after x paragraph Trying to figure out if there is a way to inject code after the first or second paragraph on a node. 

More specifically I am trying to inject an Adsense ad. 

So far I haven't been able to find a solution or module that will do this. 

Can anyone help? 

I am not using paragraphs module. Just looking how to inject code right after the third or fourth  tags on the body of the node.
Well, one way to do this would be to modify the twig template that is outputting the paragraphs (on the node).

You could loop the paragraphs render array {{ content.field_foo }}:

{% for i in content.field_foo %}
  {{ content.field_foo[i] }}

  {% if i == 1 %}
    // print your output
  {% endif %}
{% endfor %}


1 will be your second item, as the count starts at 0. This is just some rough untested pseudocode. But the idea is to loop over and print each item in the render array one by one, and inject the code at certain counts.

edit: This answer is for if you are using the Paragraphs module, which at the time of this answer is not clear from your original question.