How to append theme's product page with script and asset from app consistently programmatically

I am developing a discount app and looking to insert “Asset” and “Script” into merchant’s product page which conditionally shows that this product is in discount bundle with another product X.

I was following this tutorial: https://www.youtube.com/watch?v=0dp0Lr9Y_P4&ab_channel=ShopifyDevs And the steps I figured out were necessary were:

  1. Get /admin/themes where the theme role is main

  2. Get /admin/themes/{themeId}/assets with query asset[key]:layout/theme.liquid

  3. Find symbols in the theme body section ‘header’ and insert programatically:

{% if content_for_header contains 'script-tags.ngrok.io' &}
  {% render 'script-tag-app' %}
{% endif %}​
  1. Create a script through a POST request:
{"script_tag": {"event": "onload","src": "https://scripts-tags.ngrok.io/script}}

  1. Create a snippet through a POST request:
{"asset": {"key": "snippets/script-tag-app.liquid","value": "Some injected text
"}}

Do I understand all of this correctly? I am struggling with 2 and 3 steps.