The closest have gotten so far is wrapping head and body in a div and setting display: -moz-box (whatever that is) together with width: min-content on file. But this breaks posts without preformed text. Very unsatisfying!
// ==UserScript==
// @name Wrap Post Reply Head and Body
// @namespace http://tampermonkey.net/
// @version 1.0
// @description Wraps the head and body elements of "post-reply" class in a div
// @author You
// @match *://*/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Find all elements with class "post-reply"
const postReplies = document.querySelectorAll('.reply');
postReplies.forEach(postReply => {
// Get the head and body elements inside the post-reply
const head = postReply.querySelector(':scope > head, :scope > .head');
const body = postReply.querySelector(':scope > body, :scope > .body');
if (head || body) {
// Create a wrapper div
const wrapper = document.createElement('div');
wrapper.className = 'post-reply-wrapper';
// Wrap the head and body elements
if (head) {
wrapper.appendChild(head.cloneNode(true));
head.remove();
}
if (body) {
wrapper.appendChild(body.cloneNode(true));
body.remove();
}
// Insert the wrapper into the post-reply
postReply.appendChild(wrapper);
}
});
console.log('Post reply head and body elements wrapped successfully!');
})();