CosenseをTekenote的に使うUserScript
code:script.js
window.selectedPages = [];
const newButton = document.querySelector(".new-button")
const newButtonHref = newButton.href;
const stock = document.createElement("div");
stock.classList.add("stock");
document.body.append(stock)
const setCheckBox = () => {
document.querySelectorAll(".page-list-item").forEach((item) => {
if (item.querySelector(".item-select")) return;
const title = item.dataset.pageTitle
const checkbox = document.createElement("div")
checkbox.innerHTML = <input type="checkbox" value="${title}" class="item-select" />
item.append(checkbox)
checkbox.addEventListener("click", (e) => {
if (e.target.checked) {
window.selectedPages.push([${e.target.value}])
} else {
window.selectedPages = window.selectedPages.filter((v) => v !== [${e.target.value}]);
}
newButton.href = ${newButtonHref}?body=${window.selectedPages.join("%0A")}
stock.innerHTML = ${window.selectedPages.map((p) => <div>${p}</div>).join("")}
stock.style.display = "block";
})
})
}
window.addEventListener("load", setCheckBox);
scrapbox.on("layout:changed", setCheckBox);
window.addEventListener("scroll", setCheckBox);
code:style.css
.item-select {
position: absolute;
top: 10px;
right: 10px;
z-index: 40;
width: 16px;
height: 16px;
}
.stock {
position: fixed;
bottom: 30px;
right: 10px;
z-index: 50;
background: white;
display: none;
}