Do you live in the same school district? They do not like to pull a child out of school. Make sure her grade are passing, goes to school, up to date on dental and medical.
Your ex has to PROVE a substantial change happened to ask for custody. Since she has a history of
drug use, you can ask for testing. If she is clean, maybe at that time offer her more parenting time but that your daughter is thriving by you. Does your daughter have friends by you and into sports or school activities. Even with your daughter maybe saying that she wants to live with mom, that will not make the change by itself. Custody cases take months/years to work out so you can have your lawyer drag it out too.
Tell your daughter NOT to worry about it and that you will take care of it. Possibly bring her to a counselor now so she can talk about her feelings. A counselor YOU pick and are comfortable with (interview them first without her, it will take time to find one that you like). Have them help your daughter cope with dealing with her mother. They may even call mother and help the situation. This way you have a counselor lined up and one you like that you can use if the mother tries for custody.
You could also file now in family court that the mother will not talk to the child about court cases and who to live with. That it is bothering your daughter to choose between the families. Read your papers you already have, it might be in there already and then you can file contempt of court on her since she is putting child in the middle.
Does your daughter like being there? How is she after visits? Can you offer mom now an extra day here and there and see if she takes it? Document any extra time or any time she cancels until then.
Good luck!