script.jsscrapbox.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)}`);
}
}
});