選択範囲を辞書検索するUserScript
仕様
判定は
選択範囲が全て英数字&記号
それ以外
code:script.js
scrapbox.PopupMenu.addButton({
title: 'A',
onClick: text => {
const isJapanese = str => str.split('').some(char => char.charCodeAt() > 255);
// 記法を解除する
const keyword = text.split(/\n/)
.map(line => line.replace(/\(.*)\/g,'$1')).join('\n'); if (isJapanese(keyword)) {
window.open(https://www.ldoceonline.com/search/japanese-english/direct/?q=${encodeURIComponent(keyword)});
} else {
window.open(https://www.oxfordlearnersdictionaries.com/search/english/?q=${encodeURIComponent(keyword)});
}
}
});