UserScript:Popup-Search-Wikipedia
検索のとき、ブラケット[]は削除される
code:script.js
scrapbox.PopupMenu.addButton({
title: 'Ws',
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 uri = encodeURI(text.replace(' ', '+'));
const regexp = /^[a-zA-Z0-9!-/:-@\-`{-~\s*$/gm if (regexp.test(text)) {
window.open(https://en.wikipedia.org/w/index.php?search=${uri});
} else {
window.open(https://ja.wikipedia.org/w/index.php?search=${uri});
}
}
})
https://img.shields.io/badge/JavaScript-UserScript_Popup--Search--Wikipedia-F7DF1E.svg?logo=javascript&style=for-the-badge