I don't think this will survive constitutional challenge, because it is not the voters of the state who are deciding how the state's electors are decided. For example, would it be allowed for a swing state such as Florida which now has a Republican governor and state legislature, to pass a law stating that their state's electors would be allocated based on how Alabama votes? That way, even if the Democratic candidate won a majority of votes in Florida, the electors would still go to the Republican candidate if the Republican candidate wins in Alabama.