You can use a regular expression, for example, to extract the contents of each SCRIPT tag in your files and count the occurrence of \ n in the contents.
This regular expression must match all SCRIPT tags, including the open and close tags:
/<script[^>]*?>(.*)?</script>/sm
You should remove tags and lines without code to count the actual lines of JavaScript code.