I am dealing with a dilemma here and I cannot find a solution. Right now I have multiple PHP files with same <script></script>
tag code which contains TAWK API code. Now I want to remove that particular <script></script>
tag.
I tried a few solutions which didn't work.
- Selecting that script tag and remove it
The way I did this is
document.getElementByTagName('script')[index].innerText
The problem here is that this particular script tag is placed at random places at any given page, so I cannot put a static index number.
- IIFE to hide the Widget
TAWK API provides a method to hide the widget itself i.e.
Tawk_API.hideWidget()
but the same problem I will have to write this code in each file as TAWK API's code isn't written in one file and in each file TAWK API's code is written at last. But in some file footer.php or analytics.php occur before this which shifts the index of this script tag so this will also not work.
Any suggestions or workaround for this problem?
TL; DR: Remove script tags from multiple PHP files, but the script tag is at random location with any id.