KNo.804C
https://lh3.googleusercontent.com/a/ACg8ocI9vAsLQYO4VyWda68rrLTXk-7Q7-2PkxM8rkd5Mmj4wSK0Rw=s96-c#.png
code:メアド
kno.804c@gmail.com
自己紹介
なんやかんやでお気持ちを表明するムーブがとっても得意
UserScript
範囲選択後quoteボタンをクリックする
code:script.js
scrapbox.PopupMenu.addButton({
title: 'quote',
onClick: text => text.split(/\n/).map(line => ${line.replace(/^\s*/, '$&>')}).join('\n')
})
scrapbox.PopupMenu.addButton({
title: 'noQuote',
onClick: text => text.split(/\n/).map(line => ${line.replace(/^(\s*)([ >]*)>(| )(\s*)/, '$1$4')}).join('\n')
})
行頭の中黒をインデントに変換する(デライトで書いた箇条書きをコセンス向けに変換)
code:script.js
scrapbox.PopupMenu.addButton({
title: 'erase行頭全角中黒',
onClick: selectedText => selectedText.split(/\n/).map(line => line.replace(/^(\s *)・/, '$1 ')).join('\n') })
箇条書きを全角スペース+中黒形式に変換してクリップボードにコピーする(コセンスで書いた箇条書きをデライト向けに変換)
code:script.js
scrapbox.PopupMenu.addButton({
title: 'clipWith行頭全角中黒',
onClick: selectedText => {
const bulletToNakaguro = (text) => text.split(/\n/).map(line =>
line.replace(/^\s +/g, leadingSpaces => leadingSpaces.replace(/./g, ' ').replace(/^( *) /, '$1・')
)
).join('\n');
const copyToClipboard = (text) => {
const textArea = document.createElement('textarea');
textArea.textContent = text;
const body = document.getElementsByTagName('body')0; body.appendChild(textArea);
textArea.select();
const copyCompleted = document.execCommand('copy');
body.removeChild(textArea);
return copyCompleted;
};
const convertedText = bulletToNakaguro(selectedText);
if (!copyToClipboard(convertedText)) {
alert(Failed to Copy to clipboard.);
return;
}
alert(`Copied to clipboard.
----------------
${convertedText}`);
}
})