improve currentScript detection