UserScript:Popup-Tweet
TwitterでつぶやくスクリプトPopupMenu版
選択されたテキストをTwitterでつぶやく
code:scriptxx.js
scrapbox.PopupMenu.addButton({
title: function (text) {
const chars = 117 - text.replace(/\r\n|\|\/g, '').length
return Tw ${chars}C
},
onClick: text =>
(text.replace(/\r\n|\|\/g, '').length < 117) ?
window.open(https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(text.replace(/\[|\]/g,""))}) :
window.open(https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(text.replace(/\[|\]/g,"").substr(0,116)+"…")})
})
code:script.js
scrapbox.PopupMenu.addButton({
title: function (text) {
const ttext = scrapbox.Page.title + "\n" + text
const chars = 117 - text.replace(/\r\n|\|\/g, '').length
return TT ${chars}C
},
onClick: text => {
const twtext = scrapbox.Page.title + "\n" + text
return (twtext.replace(/\r\n|\|\/g, '').length < 117) ?
window.open(https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(twtext.replace(/\[|\]/g,""))}) :
window.open(https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(twtext.replace(/\[|\]/g,"").substr(0,116)+"…")})
}
})
元ネタ
shokai - /shokai/Tweet Menu
customize - /customize/文字カウント
うん、そのまんまだ。
scrapbox.PopupMenu.addButton()
UserScript:Page-Tweet -- ページメニュー版。考えなしにページの先頭からツイートする。
Twitter.icon
UserScript.icon
https://img.shields.io/badge/JavaScript-UserScript_Popup_Tweet-F7DF1E.svg?logo=javascript&style=for-the-badge