Detect if inside chrome extension, use correct loop