I changed it to just take the running script. I wasn't really sure of what assumptions to make. The code that was there was assuming you don't do something totally daft like have multiple script tags with the declared data attributes. But I think you are right to point out it should be more restrictive.