Fix if statement scope in bookmarklet