const post_id = 1327039; // You should do some operations before to get the desired post id
$.ajax(`/posts/${post_id}/raw.json`).then(res => {
const [text, title, raw] = res.match(/\s*#\s+([^\n]+)([\s\S]*)/);
$.ajax("/posts.json", {
type: "POST",
data: {
raw,
title,
category: YOUR_CATEGORY_ID,
},
});
});