Yoshi
code:script.js
scrapbox.PopupMenu.addButton({
title: 'DeepL',
onClick: text => {
if( text.match(/^\[\S*\]$/g) ){
text = text.replace(/\[/g, '');
}else{
text = text.replace(/\[\S*\s/g, '');
}
text = text.replace(/\]/g, '').replace(/^\s+/, '');
const regexp = /^[a-zA-Z0-9!-/:-@\-`{-~\s*$/gm
if (regexp.test(text)) {
window.open('https://www.deepl.com/ja/translator#en/ja/'
+ text
)
} else {
window.open('https://www.deepl.com/ja/translator#ja/en/'
+ text
)
}
}
})