charCount
code:script.js
const statusDom = document.createElement("div");
updateStatusDom();
scrapbox.on("layout:changed", updateStatusDom);
scrapbox.on("lines:changed", updateStatusDom);
function updateStatusDom() {
if (scrapbox.Layout !== "page") {
statusDom.remove();
} else {
document.querySelector(".status-bar").appendChild(statusDom);
const chars = scrapbox.Page.metadata.charsCount
const lines = scrapbox.Page.metadata.linesCount;
statusDom.innerText = ${lines}lines ${chars}char;
if(chars < 4096){
statusDom.style.color = null;
}else if(chars < 8192) {
statusDom.style.color = "#f80";
}else{
statusDom.style.color = "#f00";
}
}
}
scrapbox.PopupMenu.addButton({
title: function (text) {
const chars = text.replace(/\r\n/g, '').length const lines = text.split("\n").length
return ${lines}l ${chars}c
},
onClick: () => null
})