UserScript:テキストの加工
code:script.js
const iconSnipet = text => {
return(text.mapLine(line => line. sandwich("".icon")));
}
scrapbox.PopupMenu.addButton({
title: " 🙂 ",
onClick: iconSnipet
})
code:script.js
const iconLinkExchangeSnipet = text => {
let foundIcon = text. match(RegExp("\\.icon]","g"))
let func1 = line => line. replace(RegExp("\\.icon]","g"),"]")
let func2 = line => line. replace(RegExp("]","g"),".icon]")
if (foundIcon) {
return(text.mapLine(func1));
} else {
return(text.mapLine(func2));
}
}
scrapbox.PopupMenu.addButton({
title: " 😀⇔[] ",
onClick: iconLinkExchangeSnipet
})
よく使う数学記号
code:script.js
const mathSigSnipet = text => {
let func = line => line. replace(RegExp(" x ","g"), " × "). replace(RegExp(" -> ","g"), " → ")
return(text.mapLine(func));
}
scrapbox.PopupMenu.addButton({
title: " × ",
onClick: mathSigSnipet
})