UserScript:DeepL翻訳
元ネタ :
customize - /customize/shokai#592e263197c2910000308328
半角英数字記号のみ使用なら英文、それ以外は日本語の文と判定してDeepL翻訳に送る。
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
)
}
}
})
#機械翻訳
#DeepL
UserScript.icon
https://img.shields.io/badge/JavaScript-UserScript_DeepL翻訳-F7DF1E.svg?logo=javascript&style=for-the-badge