script.js scrapbox.PopupMenu.addButton({
title: 'Append',
onClick: text => {
const lines = text.split(/[\r\n]/g)
const title = lines[0]
.trim()
.replace(/\[[^\]]+.icon\]/gm, '')
.replace(/[\[\]]/g, '')
const projectRoot = (() => {
const tmp = location.href.split('/')
tmp.pop()
return tmp.join('/')
})()
const currentPageTitle = decodeURIComponent(location.href.split(/\//g).pop())
lines.shift()
const body = encodeURIComponent(lines.join('\n'))
window.open(`${projectRoot}/${title}?body=${body}`)
return `${text}`
}
})