I don't think Candidate X's declaration would put much pressure on Candidate Y. Y can just say "I believe in democracy too, but I think that the founders of this great nation (pause for applause) knew what they were doing when they put in place a system that has served us well for over two hundred years. And I believe in the Constitution of the United States (pause for more applause) and I think that if we want to change how it works we should do it by the means laid down in that Constitution. I will not be joining Candidate X's attempt to undermine the Constitution, and I ask my electors to vote for me as the founders of this great nation (pause for even more applause) intended."
I don't mean that everyone will agree when Candidate Y says that. But everyone will think it plausible enough that Candidate Y means it that Candidate Y won't lose much credibility by declining to make the same pledge as X has.
(I don't think the recent midterms are much evidence against this; I think the things voters seem to have penalized somewhat in those elections are quite different in kind from "declining to ask one's electors to give the election to the other guy if he wins the national popular vote".)
So this scheme is dependent on candidates' willingness to take unilateral actions that can only hurt them and have a significant chance of handing the election to the other candidate. Even a candidate who thinks the national popular vote is a much better indicator of the Will Of The People than the electoral college vote, and who is keen to be sees to love democracy, is likely to be reluctant to do that.
And unless there's (not just one candidate's declaration, not just both candidates' declarations, but) a robust agreement by both sides' party machinery that this is the way to go in all future elections, this (unlike NaPoVoInterCo) doesn't fix things permanently or even lastingly. It can happen in one election and then unhappen in the next one.
I do think it's an interesting idea, but it looks like a non-starter to me.
Why are people focusing on symptoms, and not on causes? Electoral college, however archaic it is, works fine if the vote is not nearly evenly split. It also does not matter all that much which party wins in an evenly-split society... or would not if polarization was not as extreme as it is now in the US. What you are proposing does not address the causes at all, instead trying to "fix" the system in favor of one party. Would you be as inclined to want the same reforms if it was "your" party benefiting from the status quo?
There's currently a campaign to do an end-run around the United States' electoral college system, the National Popular Vote Interstate Compact. (There's a lot of reasons why you might or might not want to abandon the electoral college system, which I will not discuss here.) If you've never heard of NaPoVoInterCo I recommend this fun and animated CGP Grey explanation. Basically, signatory states agree to send electors for whoever wins the national popular vote for president, but only when enough states have signed on that they have a controlling majority of the electoral college. In theory, this would mean the electors meeting to choose the president just vote for the winner of the national popular vote, not whoever won their state. (As Grey mentions, this would almost certainly end up with a supreme court fight if the winner of the electoral college and the national popular vote were not the same person.)
It occurred to me the other day that a major party presidential candidate stands a good chance to pull off a similar end-run, given the right conditions. I don't think this plan is likely to be attempted by anyone currently in politics who would be in a position to do so, and I can think of a lot of reasons why it might not work. But the idea interested me enough that I thought I'd write it out.
Here is the plan: Candidate X supports replacing the electoral college with a national popular vote. All they have to do is go on TV and say "I believe in democracy! In fact, I believe in it so much that I don't want to be president without winning a popular vote. So if it turns out that I win the electoral college but not the national popular vote, I would like my electors to vote for Candidate Y." (A professional speech writer should fit in more applause lights; public support and pressure would be critical for this scheme to work.)
This might make X's party election strategists explode with frustration, since the candidate keeping their word means they now have fewer ways to win. However, if they wait a little while, they may see that the announcement results in pressure for the opponent to make the same pledge (and ultimately, this is the goal). Provided both candidates believe in a national popular vote over the electoral college, or at least want to look like they "love democracy" (which, I'll grant, is not a sure thing), it's plausible that Candidate Y would match the pledge. In a two party system that would put a soft end to the electoral college victories of popular vote-minority presidents, since both camps would agree that the popular vote winner should be made president - though the agreement would be backed by honor (or the threat of instability and constitutional crisis if one side backs out) rather than law. And of course, electors don't have to vote for the candidate they've pledged their vote to ("faithless electors"), so there's no way to assure that electors vote for the candidate they've pledged to vote against.
If the opponent doesn't agree to throw the electoral college if they lose the national popular vote, this would probably be seen as an anti-democratic or dishonorable position. To the extent that voters care about that, it would probably hurt them. The most recent US midterms seem to indicate that voters respond negatively when candidates behave in ways that are anti-democratic or that can be described as anti-democratic by their opposition. Whether or not this is worth giving up the possibility of an electoral college win without a popular majority would depend on the candidate and the political moment.