UserScript:Page-Tweet
元ネタ
本文を先頭から Twitter に送る。
code:scriptxx.js
scrapbox.PageMenu.addItem({
title: 'Tweet',
//onClick: () => window.open(https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(window.scrapbox.Page.title)})
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')
(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)+"…")}) ;
}
})
code:script.js
scrapbox.PageMenu.addMenu({
title: 'X(twitter)',
})
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')
(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')
(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")});
}
})
Twitter.icon
UserScript.icon
https://img.shields.io/badge/JavaScript-UserScript_Page_Tweet-F7DF1E.svg?logo=javascript&style=for-the-badge