UserScript:Scaffolding-05
script.jsconst l5links = text => {
const regexp = /^[a-zA-Z0-9!-/:-@\[-`{-~\s]*$/gm
if (regexp.test(text)) {
return `[/icons/wikipedia.icon][https://en.wikipedia.org/w/index.php?search=${encodeURIComponent(text)} ${text}]\n`
+ `[/icons/google.icon][https://www.google.com/search?q=${encodeURI(text.replace(' ', '+'))} ${text}]\n`
+ `[/icons/twitter.icon][https://twitter.com/search?q=${encodeURI(text.replace(' ', '+'))} ${text}]\n`
+ `Urban Dictionary [https://www.urbandictionary.com/define.php?term=${encodeURI(text.replace(' ', '+'))} ${text}]`
} else {
return `[/icons/wikipedia.icon][https://ja.wikipedia.org/w/index.php?search=${encodeURIComponent(text)} ${text}]\n`
+ `[/icons/google.icon][https://www.google.com/search?q=${encodeURI(text.replace(' ', '+'))} ${text}]\n`
+ `[/icons/twitter.icon][https://twitter.com/search?q=${encodeURI(text.replace(' ', '+'))} ${text}]`
}
}
scrapbox.PopupMenu.addButton({
title: 'L5',
onClick: l5links
})