scrapbox2markdown
code:script.user.js
(function () {
var m = function (b) {
b = b.replace(/&/g, "&");
b = b.replace(/</g, "<");
b = b.replace(/>/g, ">");
b = b.replace(/"/g, """);
return b = b.replace(/'/g, "'")
},
n = function (b) {
b = void 0 === b ? 0 : b;
/* for (var a = "", g = 1; g < b; g++) a += " "; */
for (var a = "", g = 1; g < b; g++) a += "\t";
return a
},
p = function (b) {
b = void 0 === b ? "" : b;
var a = document.createElement("div");
a.innerHTML = b;
b = a.querySelectorAll("strong");
for (var g = 0; g < b.length; g++) {
e = +d.className.split("level-")1, c = d.innerHTML;
e = void 0 === e ? 1 : e;
e = 6 - e;
for (var f = "", h = 0; h < e; h++) f += "#";
d.innerHTML = f + " " + c
}
return a.innerHTML
},
q = function (b) {
b = void 0 === b ? "" : b;
var a = document.createElement("div");
a.innerHTML = b;
b = a.querySelectorAll("a");
for (var g = 0; g < b.length; g++) {
e = d.innerText.trim(),
c = d.href;
e = "+ e + "(" + c + ")";
var f = d.querySelector("img");
null !== f && (e = "[!Image(" + f.src + ")](" + c + ")"); d.innerText = e
}
return a.innerText
},
f = document.querySelector(".lines"),
r = f.querySelector(".line-title .text").innerText;
f = f.querySelectorAll(".line");
pageTexts = [];
for (var l = 1; l < f.length; l++) {
for (var c = fl.querySelector(".text").cloneNode(!0), h = c.querySelectorAll("span.empty-char-index"), a = 0; a < h.length; a++) { k.innerText = ""
}
h = c.querySelectorAll("span.backquote");
for (a = 0; a < h.length; a++) k = ha, k.innerText = "`"; a = c.innerHTML.replace(/<span>/g, "");
a = a.replace(/<span.+?>/g, "").replace(/<\/span>/g, "");
a = a.replace(/<br.+?>/g, "");
a = a.replace(/\n/gi, "").replace(/\t/gi, "").trim();
a = p(a);
a = q(a);
c = c.querySelector(".indent-mark");
null !== c && (k = +c.style.width.split("em")0 / 1.5 * 2, a = n(k) + "- " + a); /* null === c && 0 < a.length && "#" !== a0 && (a += "<br>"); */ null === c && 0 < a.length && "#" !== a0 && (a += ""); pageTexts.push(a)
}(function (b, a) {
b = void 0 === b ? "Title" : b;
a = void 0 === a ? [] : a;
for (var c = "# " + b + "\n", d = 0; d < a.length; d++) c += "\n" + ad; a = window.open();
a.document.open();
a.document.write("<title>" + b + "</title>");
a.document.write("<pre>");
a.document.write(m(c));
a.document.write("</pre>");
a.document.close()
})(r, pageTexts)
})();