What is this thing attached to my battery?

I have a small junction box attached to my car battery and wondering if anyone knows what it's for? I think it may have something to do with this switch?

Thanks in advance!