generated at
ScrapboxのメニューにTweet Buttonを追加するUserScript
一行目だけをツイートするテスト

script.js
scrapbox.PageMenu.addMenu({ title: 'tweet', image: 'https://i.gyazo.com/c3422b30448f1026b32cde0d8afc3325.png', onClick: () => { const encodedUrl = encodeURIComponent(location.href); const encodedTitle = encodeURIComponent(window.scrapbox.Page.title); window.open(`https://twitter.com/intent/tweet?url=${encodedUrl}&text=${encodedTitle}`) } }); /* scrapbox.PageMenu('tweet').addItem({ title: 'Tweet with 1st line & link', image: 'https://twitter.com/favicon.ico', onClick: () => window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(window.scrapbox.Page.lines[1].text)}`) }); scrapbox.PageMenu('tweet').addItem({ title: 'Tweet with title, 1st line & link', image: 'https://twitter.com/favicon.ico', onClick: () => window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(window.scrapbox.Page.title + '\r\n' + window.scrapbox.Page.lines[1].text)}`) }); scrapbox.PageMenu('tweet').addItem({ title: 'Tweet only 1st line', image: 'https://twitter.com/favicon.ico', onClick: () => window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(window.scrapbox.Page.lines[1].text)}`) }); */