generated at
aki

いるとこ

作ったもの
はてなブログのテーマ
HTMLをMarkDownで表現するテーマ
記事を情報カード風に表示するテーマ
書くことに集中するためのエディタ

hr

Timestamp
script.js
scrapbox.TimeStamp.addFormat('YYYY-MM-DD'); scrapbox.TimeStamp.addFormat('HH:mm');

script.js
const __bkmClass = '.deco-\\.' /* ここで記法のセレクタを設定してね。デフォルトはドットです */ const __bkmMenuTitle = 'Bookmarks' scrapbox.PageMenu.addMenu({ title: __bkmMenuTitle, image: 'dummy.png', onClick: function() { const __fixedHeaderHeight = ($('.navbar').css('position') == 'fixed' ? $('.navbar').height() : 0) + ($('.navbar-pagemenu').height() || 0) scrapbox.PageMenu(__bkmMenuTitle).removeAllItems() $(__bkmClass).closest('.line').each(function(i, e){ scrapbox.PageMenu(__bkmMenuTitle).addItem({ title: $(e).find(__bkmClass).text(), onClick: function() { $('html,body').animate({ scrollTop: $(e).offset().top - $('body').offset().top - __fixedHeaderHeight }, 150) } }) }) } })

Tweet
script.js
scrapbox.PageMenu.addItem({ title: 'Tweet', onClick: () => window.open(`https://twitter.com/intent/tweet?url=${encodeURIComponent(location.href)}&text=${encodeURIComponent(document.title)}`) })


ランダム
script.js
scrapbox.PageMenu.addItem({ title: 'Random', onClick: function () { const r = /scrapbox\.io\/([^\/.]*)/ const p = location.href.match(r)[1]; jQuery.getJSON("/api/pages/"+p+"?limit=10000",function (d) { const i = Math.floor(Math.random() * d.count); location.href="/"+p+"/"+d.pages[i].title.replace(/\//g,"%"+"2f") }) } })

script.js
setTimeout(function() { if (scrapbox.Page.lines) { const fmt = function(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 chars = scrapbox.Page.lines.map(l => { return l.text }).join('').length const counter = $(`<span>${fmt(chars)} chars</span>`).css('opacity', '.45').appendTo(counterWrapper) counter.hover( function() { $(this).css('opacity', '.5') const chars = scrapbox.Page.lines.map(l => { return l.text }).join('').length const words = scrapbox.Page.lines.map(l => { return l.text }).join(' ').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\n${fmt(words)} words\n${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.Page.lines) { const chars = scrapbox.Page.lines.map(l => { return l.text }).join('').length $('#__charCounter__ span').text(`${fmt(chars)} chars`) } } $('#text-input').on('input', updateCounter).on('paste', updateCounter) setInterval(updateCounter, 3000) } }, 1000)

Zen Mode
script.js
scrapbox.PageMenu.addItem({ title: 'Zen mode', onClick: (e) => { var bg = 'white' // ここにお好きな背景色を入れてね(テーマの背景が黒なら black で) var style = document.getElementById('__zen__') if (style) { style.remove(); e.currentTarget.innerText = 'Zen mode'; return } else e.currentTarget.innerText = String.fromCharCode(0x02713) + ' Zen mode' var css = `body, .page { background-color:${bg} !important; background-image:none !important }` + '.navbar:not(:hover), .line .meta:not(:hover), .col-page-side:not(:hover) { opacity:0 }' style = document.createElement('style') style.setAttribute('id', '__zen__') style.appendChild(document.createTextNode(css)) document.head.appendChild(style) } })