Detection script

Thanks to AND for this script!