ページの左側に別のページの内容を表示させるUserScript
サンプル画面
https://gyazo.com/d5abf49a037172ec450f05f26761f2b3
ボタンを押すと表示、もう一度押すと消去
code:script.js
scrapbox.PageMenu.addMenu({
title: '一覧',
onClick: () => {
if (document.getElementById("tempThemeList")){
document.getElementById("tempThemeList").remove();
return
}
const tempBody = getBodyText("%E5%80%89%E4%B8%8B%E5%BF%A0%E6%86%B2%E3%81%AE%E4%B8%BB%E8%A6%81%E3%81%AA%E9%96%A2%E5%BF%83%E4%BA%8B")
async function getBodyText(encodedPageTitle){
const url = https://scrapbox.io/api/pages/${scrapbox.Project.name}/${encodedPageTitle}/text;
const response = await fetch(url);
if (!response.ok) {
throw new Error(${response.status} ${response.statusText});
}
const text = await response.text();
const divBody = document.createElement("div")
divBody.id = "tempThemeList"
divBody.innerText = text
console.log(divBody)
const appContainer = document.querySelector(".app .container .page-column")
appContainer.append(divBody)
}
}
})
code:style.css
position: absolute;top: 72px;left: 20px;background: floralwhite;padding: 1em;
width:300px;border-radius: 5px;
}