var textArr = [];
for (
let index = 0;
index < document.querySelectorAll("p").length;
index++
) {
textArr.push(document.querySelectorAll("p")[index].innerHTML);
}
var exporTXT = textArr.join("");
var element = document.createElement("a");
element.setAttribute(
"href",
"data:text/plain;charset=utf-8," + encodeURIComponent(exporTXT)
);
element.setAttribute("download", "第一章");
element.click();
直接复制粘贴即可,开箱即用