re-wrote detect.js and debug.html