script.jsscrapbox.PageMenu.addMenu({
title: 'X(twitter)',
image: 'https://scrapbox.io/api/pages/suto3/ツイッター/icon#.png',
})
scrapbox.PageMenu('Twitter').addItem({
title: 'Tweet',
onClick: () => {
//const body = window.scrapbox.Page.lines.map(line => line.text).join('\n');
const body = window.scrapbox.Page.lines
.map(line => line.text)
.join('\n')
.replace(/\[|\]/g, '');
(body.length < 117) ?
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(body)}`)
:
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(body.substr(0,116)+"…")}`) ;
}
})
scrapbox.PageMenu('Twitter').addItem({
title: 'Hash Tw',
onClick: () => {
const body = window.scrapbox.Page.lines
.map(line => line.text)
.join('\n')
.replace(/\[|\]/g, '');
(body.length < 108) ?
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(body+" #Cosense")} `)
:
window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(body.substr(0,107)+"… #Cosense")}`);
}
})