ootaki-masahiro
https://gyazo.com/25abf49f0adbc9279e5e93446d583fc1
code:import.js
import '/api/code/scrasobox/WebからコピペしたらSB記法に変換する/script.js'
選択範囲をtweetするUserScript
code:script.js
scrapbox.PopupMenu.addButton({
title: 'Tweet',
onClick: text => {
const lines = text
.map(line => line.replace(/[\\]/g, '').replace(/^\s+/, '')) lines.push(location.href)
const url = https://twitter.com/intent/tweet?&text=${encodeURIComponent(lines.join('\n'))}
const width = 550
const height = 420
const option = width=${width},height=${height},left=${(window.innerWidth - width) / 2},top=${(window.innerHeight - height) / 2},scrollbars=yes,resizable=yes,toolbar=no,location=yes
window.open(url, '_blank', option)
}
})
日付書式
code:script.js
scrapbox.TimeStamp.addFormat("_[]YYYY/MM/DD[]")
scrapbox.TimeStamp.addFormat("]YYYY/MM/DD[ HH:mm")
scrapbox.TimeStamp.addFormat("]YYMMDD[-HHmm=")
scrapbox.TimeStamp.addFormat("[]YYYY/MM/DD[] ")
scrapbox.TimeStamp.addFormat("[YYYY/MM/DD[] ]")
scrapbox.TimeStamp.addFormat("]YYYY/MM/DD[")
scrapbox.TimeStamp.addFormat("]YYYY/MM/DD[ HH:mm")
UserScript
code:script.js
scrapbox.PopupMenu.addButton({
title: function (text) {
const chars = text.replace(/\r\n/g, '').length const words = text.trim().split(/\r\n\s+/).length return ${chars}c ${words}w
},
onClick: () => null
})
code:script.js
scrapbox.PopupMenu.addButton({
title: 'quote',
onClick: text => text.split(/\n/).map(line => > ${line}).join('\n')
})
code:script.js
scrapbox.PopupMenu.addButton({
title: 'NewPage',
onClick: text => {
const lines = text.split(/\r\n/g) .trim()
.replace(/\^\+.icon\]/gm, '')
const projectRoot = (() => {
const tmp = location.href.split('/')
tmp.pop()
return tmp.join('/')
})()
const currentPageTitle = decodeURIComponent(location.href.split(/\//g).pop())
lines.unshift(from [${currentPageTitle}])
const body = encodeURIComponent(lines.join('\n'))
window.open(${projectRoot}/${title}?body=${body})
return [${title}]
}
})
code:script.js
(() => {
if (!webkitSpeechRecognition) return
const isMobile = () => /mobile/i.test(navigator.userAgent)
const writeText = text => {
console.log('writeText', text)
document.querySelector('.text-input').focus()
document.execCommand('insertText', null, text)
}
const recognition = new webkitSpeechRecognition()
if (!isMobile()) recognition.continuous = true
recognition.onresult = (e) => {
writeText(item.transcript + '\n')
}
let enable = false
scrapbox.PageMenu.addMenu({
title: 'speech input',
})
scrapbox.PageMenu('speech input').addItem({
title: () => (enable ? 'Stop' : 'Start') + ' speech input',
onClick: () => {
if (!enable) recognition.start()
else recognition.stop()
if (!isMobile()) enable = !enable
}
})
})()
hr.icon