junkaneko
https://lh5.googleusercontent.com/-THJ4Yqs7Lgk/AAAAAAAAAAI/AAAAAAAAIwA/o6Izb-ODFJo/photo.jpg
this is junkaneko’s page
zenモード
code:script.js
scrapbox.PageMenu.addItem({
title: 'Zen mode',
onClick: e => {
var bg = 'black' // ここにお好きな背景色を入れてね(テーマの背景が黒なら 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 .telomere: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)
}
})
しおり記法
code:script.js
// 選択した文字列にマーカー
scrapbox.PopupMenu.addButton({
title: 'しおり',
onClick: text => [. ${text}]
})
code:style.css
/* しおり記法 -- 栞箇所のマークやハイライトが不要な場合はこのブロックは消してね */
@media screen {
body:not(.presentation) .line .deco-\.::after {
position: absolute; top: 3px; left: -1.4em;
content: '\f02e'; font: 1.7rem/1 'FontAwesome 5 Free'; color: yellowgreen } }
@media screen and (max-width: 990px) {
body:not(.presentation) .line .deco-\.::after { position: static; padding-left: .3em } }
/* 栞一覧を出すページメニューボタンのスタイル -- ここは必要 */
button#Bookmarks.tool-btn:hover { text-decoration: none }
button#Bookmarks.tool-btn::before { position: absolute; content: '\f02e'; font: 400 20px/46px 'Font Awesome 5 Free' }
button#Bookmarks.tool-btn img { opacity: 0 }
code: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)
}
})
})
}
})
蛍光緑マーカー
code:script.js
// 選択した文字列にマーカー
scrapbox.PopupMenu.addButton({
title: 'マーカー',
onClick: text => [[${text}]]
})
code:style.css
/* 二重括弧による強調をマーカーっぽくする */
.line strong:not(class) { background: linear-gradient(transparent 10%, #ABFF4F 25%, #ABFF4F 70%, transparent 90%) }
文字装飾記法
code:style.css
.deco-\# {
background-color: #6a6; /* 緑背景 */ }
.deco-\! { /* 重要な部分は!を付ける */
background-color: #e66; /* 赤背景 */ font-size: 1.2em; /* 重要なので最初から大きな文字にする */
}
userscript
code:script.js
// 選択された文字列をScrapboxプロジェクト内で検索する
// Scapbox検索ボックスを使ったときと同じ結果ページを開く
scrapbox.PopupMenu.addButton({
title: 'スクボ内検索',
onClick: function (text) {
var projectName = 'daiiz';
}
});
関連ページを吹き出し表示するJS
code:style.css
box-shadow: 0 2px 2px 0 rgba(0,0,0,.14),0 3px 1px -2px rgba(0,0,0,.2),0 1px 5px 0 rgba(0,0,0,.12);
position: absolute;
display: none;
padding: 10px;
box-sizing: content-box;
z-index: 10000;
}
.daiiz-cards {
height: 100%;
overflow-x: auto;
overflow-y: hidden;
white-space: nowrap;
}
.daiiz-cards li {
float: none !important;
}
display: inline-block;
white-space: normal;
}
code:script.js
var bindEvents=function(b){var c=null;b.on("mouseenter","a.page-link",function(a){a=$(a.target).closest("a.page-link");if(!a.hasClass("empty-page-link")){var d=$getRelCardBubble(b),e=a0.getBoundingClientRect();d.css({"max-width":$(".editor-wrapper")0.offsetWidth-a0.offsetLeft,left:e.left+window.pageXOffset,top:e.top+window.pageYOffset+a0.offsetHeight+3-24,"background-color":$("body").css("background-color")});a=a0.innerText.replace(/^#/gi,"").split("#")0;a.startsWith("/")?d.hide():($cards= $getRelCards(a),0===$cards.children().length?d.hide():(d.find(".daiiz-cards").remove(),d.append($cards),d.css({height:$("li.relation-label").css("height")}),c=window.setTimeout(function(){d.show()},650)))}});b.on("mouseleave","a.page-link",function(a){window.clearTimeout(c)});b.on("mouseleave","#daiiz-rel-cards-bubble",function(a){a=$getRelCardBubble(b);window.clearTimeout(c);a.hide()});b.on("click",function(){var a=$getRelCardBubble(b);window.clearTimeout(c);a.hide()})},$getRelCardBubble=function(b){var c=
$("#daiiz-rel-cards-bubble");0===c.length&&(c=$('<div id="daiiz-rel-cards-bubble" class="related-page-list"></div>'),b.find(".page").append(c));return c},$getRelCards=function(b){$(".daiiz-cards").remove();for(var c=$(".relation-label"),a=$('<div class="daiiz-cards grid"></div>'),d=0;d<c.length;d++){var e=$(cd);if(e.find(".title")0.innerText===b){e=e.next("li.page-list-item");a.append(e.clone(!0));for(var f=0;1===e.length&&200>f;)e=e.next("li.page-list-item"),a.append(e.clone(!0)),f++}}return a}; $(function(){var b=$("#app-container");bindEvents(b)});
ページの1部分を別のページに切り出すUserScript
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}]
}
})
Google翻訳
code:script.js
scrapbox.PopupMenu.addButton({
title: 'Google翻訳',
onClick: text => window.open(https://translate.google.com/#ja/en/${text})
})
ページ内の文字カウント
code:page.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
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
})