Fix "Error: Permission denied to access property 'document'"