nishio
これはScrapboxの仕様上、あるとベターな個人ページです。
https://gyazo.com/03051565f03a70a83b182fda5965e187
こうやって個人ページを作っておくとCtrl+iでアイコンが出るようになる
画像の貼られたページを最初にピン止めしておくことでそれがFaviconになり、ブラウザのタブなどでわかりやすい。
自己紹介
西尾泰和
https://gyazo.com/c078c5aa55ddbddd85530c5136b163e8
-----以下個人的なカスタマイズのためのユーザースクリプトなど-----
全角半角変換などをする「format」メニュ (from /shiology)
1. 箇条書きの先頭を全てTabに置き換える
2. 文中の全角・半角空白を取り除く
3. 文字化けを修正する (今回は での を での に直す)
4. 全角英数字を半角英数字に置き換える
5. 全角括弧を半角括弧に置き換える
6. 括弧で囲まれた前後に空白を入れる
7. コードブロック記法の前後に空白を入れる
code:script.js
scrapbox.PopupMenu.addButton({
title: 'format',
onClick: text => text.split('\n').map(function(line) {
return line.replace(/^\s*/g, s => s.replace(/\s/g, '\t'))
// .replace(/  /g, '')
.replace(/ぁ-ん|ァ-ヴ゙/g, s => String.fromCharCode(s.charCodeAt(0) + 1))
.replace(/A-Za-z0-9/g, s => String.fromCharCode(s.charCodeAt(0) - 0xFEE0))
.replace('(', '(')
.replace(')', ')')
.replace(/\S\(/g, s => s.charAt(0) + ()
.replace(/\)\S/g, s => ') ' + s.charAt(1))
.replace(/\S.*/g, s => s.charAt(0) + ' ' + s.slice(1))
.replace(/.*\S/g, s => s.slice(0, -1) + ' ' + s.slice(-1))
}).join('\n')
})
Scrapbox横断検索
code:script.js
var pagename = document.location.pathname.split("/").pop();
if(pagename == "cross_search"){
console.log(pagename);
var query = document.location.search.substr(1);
var page = document.getElementsByClassName("page")0;
page.innerHTML = "<iframe width='50%' height='2000px' src='https://scrapbox.io/rashitamemo/search/page?q=" + query +
"'></iframe><iframe width='50%' height='2000px' src='https://scrapbox.io/nishio/search/page?q=" + query + "'></iframe>" + page.innerHTML;
}
/masui/検索してみつからなければ新規作成
改行キーで新規ページ作成
code:script.js
$('body').on('keydown',function(e){ // Enterキーで新規ページ作成
if(e.target.tagName != "TEXTAREA" && e.target.tagName != "INPUT"){
if(e.key == 'Enter'){
var project = location.href.split('/')3;
location.href = /${project}/new;
}
}
});
$('.btn.btn-default').on('click',function(){
var s = $('.form-control').val();
if(s == ''){
var project = location.href.split('/')3;
location.href = /${project}/new;
}
});
タイムタギング
年のタグ、月日のタグ、年月のタグを作る。「何年ごろ何やってたかな」もできるし「何年の何月ごろ」と狭めることもできる。月日のタグは「過去のこの日」に使う。
code:script.js
scrapbox.PopupMenu.addButton({
title: "TimeTag",
onClick: (text) => {
var m = text.match(/((\d\d)?(\d\d))-?(\d\d)-?(\d\d)/);
var year = "20" + m3;
var month = m4;
var day = m5;
return ${year}-${month}-${day} #${year} #${month}-${day} #${year}-${month};
}
})
2018-09-19 日時のフォーマットを←にする
code:script.js
window.scrapbox.TimeStamp.removeAllFormats()
window.scrapbox.TimeStamp.addFormat("YYYY-MM-DD")
2018-06-22
code:script.js
import '/api/code/nishio/抜き書きUserScript/script.js'
see 抜き書きUserScript
2018-06-12
小さくする
code:script.js
var elm=document.createElement('span');
elm.append("ZoomOut")
elm.onclick = ()=>{
document.getElementsByClassName("page-list")0.setAttribute('style', 'zoom: 0.5')
document.getElementsByTagName('body')0.webkitRequestFullscreen()
}
document.getElementsByClassName("search-form")0.parentElement.append(elm)
2018-05-25
/customize/「過去のこの日」機能
code:script.js
import '/api/code/nishio/ScrapboxSRS/script.js'
音声入力
2018-04-15
/shokai/音声入力Menu
code:script.js
import '/api/code/shokai/音声入力Menu/script.js'
塩澤先生のプロジェクトから
tweetメニュ
code:script.js
scrapbox.PageMenu.addItem({
title: 'Tweet',
image: 'https://twitter.com/favicon.ico',
onClick: () => window.open(https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(document.title)})
})
文字数カウントメニュ
code:script.js
scrapbox.PageMenu.addItem({
title: () => {
if (!scrapbox.Page.lines) return
const chars = scrapbox.Page.lines.map(line => line.text.length).reduce((a,b) => a + b)
const words = scrapbox.Page.lines.map(line => line.text.split(/\s+/).length).reduce((a,b) => a + b)
return ${chars}文字 ${words}単語 ${scrapbox.Page.lines.length}行
},
onClick: () => null
})
文字数カウンタ
code:script.js
const __charCounterProject__ = scrapbox.Project.name
const __charCounterSetup__ = setInterval(function() {
if (document.getElementById('editor') && scrapbox.Page.lines)
clearInterval(__charCounterSetup__)
else
return
const fmt = (n) => { return new Intl.NumberFormat('en-US').format(n).padStart(6) }
$('<pre id="__charCounterPopup__"></pre>').css('opacity', '0').appendTo('body')
const counterWrapper = $('<div id="__charCounter__"></div>').appendTo('#editor')
const linesText = document.querySelector('.lines').innerText
const chars = linesText.split(/\s+/).join('').length
const counter = $(<span>${fmt(chars)} chars</span>)
.css('opacity', '.45').appendTo(counterWrapper)
counter.hover(
function() {
$(this).css('opacity', '.85')
// page texts without title
const linesText = document.querySelector('.lines').innerText
const chars = linesText.split(/\s+/).join('').length
const words = linesText.split(/\s+/).length
const w = document.getElementById('__charCounter__')
const posX = (window.innerWidth - w.offsetWidth) / 2
const posY = w.offsetTop + w.offsetHeight
$('#__charCounterPopup__')
.html(`${fmt(chars)} chars
${fmt(words)} words
${fmt(scrapbox.Page.lines.length)} lines`)
.css('top', calc(${posY}px - .2em))
.css('right', calc(${posX}px - 3em))
.css('opacity', '1')
},
function() {
$(this).css('opacity', '.45')
$('#__charCounterPopup__').css('opacity', '0')
}
)
const updateCounter = function() {
if (scrapbox.Project.name !== __charCounterProject__
|| document.querySelector('body.presentation')) {
$('#__charCounter__ ').hide()
} else if (scrapbox.Page.lines) {
const linesText = document.querySelector('.lines').innerText
const chars = linesText.split(/\s+/).join('').length
$('#__charCounter__ span').text(${fmt(chars)} chars)
$('#__charCounter__ ').show()
}
}
$('#text-input').on('input', updateCounter).on('paste', updateCounter)
setInterval(updateCounter, 3000)
}, 3000)
選択文字列をプロジェクト内で検索ポップアップ
code:script.js
// 選択された文字列をScrapboxプロジェクト内で検索する
// Scapbox検索ボックスを使ったときと同じ結果ページを開く
scrapbox.PopupMenu.addButton({
title: 'SB内検索',
onClick: function (text) {
var projectName = 'shio';
window.open('https://scrapbox.io/'+ projectName +'/search/page?q=' + text);
}
});
---
ページの1部分を新規ページに切り出す
code:script.js
scrapbox.PopupMenu.addButton({
title: 'NewPage',
onClick: text => {
const lines = text.split(/\r\n/g)
const title = lines0
.trim()
.replace(/\^\+.icon\]/gm, '')
.replace(/[\\]/g, '')
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}]
}
})