UserScript:Page-Tweet
Twitter でつぶやくページメニュー版
元ネタ
shokai - /shokai/Tweet Menu
本文を先頭から Twitter に送る。
code:scriptxx.js
scrapbox.PageMenu.addItem({
title: 'Tweet',
image: 'https://twitter.com/favicon.ico'
//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')
.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)+"…")}) ;
}
})
code:script.js
scrapbox.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")});
}
})
scrapbox.Page.lines
UserScript:Popup-Tweet - ポップアップメニュー版
Twitter.icon
UserScript.icon
https://img.shields.io/badge/JavaScript-UserScript_Page_Tweet-F7DF1E.svg?logo=javascript&style=for-the-badge