Trying to write a script that will add a button (or even use a bookmarklet) to toggle Conversation View on and off.

This works, some of the time, to do the toggling:

window.location.href = ""+window.location.pathname+"#settings/general";
setTimeout(function() {
    convTogs = document.getElementsByName("bx_vmb");
        if (convTogs[0].checked) convTogs[1].click(); 
        else convTogs[0].click();
}, 5000);

This adds the button where I want it:

var btn = document.createElement("div"); = "cvtoggle";
btn.innerHTML = "ConversationView";
btn.setAttribute("onclick", _____code____);
document.getElementsByClassName("Cr aqJ")[0].prepend(btn)

The method of going to Settings is poor; it causes a full refresh.

The selector for the "Setting" link in the gear menu is
document.querySelector('#ms > div')
but I can't figure out how to "click" it.