まなてぃ
https://i.gyazo.com/e3c319730c8f53a81fcb94e880275020.png
■プロフィール
元IT企業の人→フリーランス→派遣社員&ズボラ主婦。
のんびりブログを書いています。データ集計や事務関係のお仕事をしています。
まなてぃの好きなことリスト
個人的なこと
骨格ストレート✕イエベ春(イエローベース・スプリング)らしい
MBTI診断: ISTJ-TC
まなてぃの発信
ブログ: まなてぃのぽよーんろぐ
Bluesky
体当たりうっくんチャンネル - YouTube
音声配信: LISTEN
その他リンクまとめ: lit.link
---.icon
免責事項・プライバシーポリシー
---.icon
⚙️設定
templateページの today.js を実行し、日記テンプレートを作成するスクリプト
参考
code:script.js
// UserScriptとしてユーザーページに追加する
addTemplateItemsToPageMenu()
function addTemplateItemsToPageMenu() {
// テンプレートメニューの定義ここから ----------
const __templates = [
{ title: '🍎today', url: '/api/code/manatee-poyon/template/today.js'},
{ title: '🍊tomorrow', url: '/api/code/manatee-poyon/template/tomorrow.js'},
{ title: '🍏weekly', url: '/api/code/manatee-poyon/template/weekly.js'},
{ title: '🍌monthly', url: '/api/code/manatee-poyon/template/monthly.js'},
{ title: '🍍TOBE-circle', url: '/api/code/manatee-poyon/template/tobe_circle.js'}
// メニューを追加する場合は、同じように行を追加する。
// titleにはテンプレートメニューに表示する名前を、urlはそのテンプレートがあるスクリプトのURLを指定する
// `api/code/{自分のユーザー名}/{テンプレートファイルを置いているページ名}/{テンプレート名}.js
]
// テンプレートメニューの定義ここまで ----------
const __templateMenuTitle = 'Templates'
scrapbox.PageMenu.addMenu({ title: __templateMenuTitle, image: 'https://i.gyazo.com/2cff7232f4e2448781bc3e6a3480234a.png', onClick: () => { } })
__templates.forEach((template) => {
scrapbox.PageMenu(__templateMenuTitle).addItem({
title: template.title,
onClick: () => { __loadTemplate(template.url) }})
})
const __loadTemplate = templateUrl => {
if (scrapbox.Page.lines && scrapbox.Page.lines.length == 1) {
const line = document.getElementById('L' + scrapbox.Page.lines0.id)
const lastChar = line.querySelector('span.char-index:last-of-type')
const textarea = document.getElementById('text-input')
lastChar.dispatchEvent(new MouseEvent('click', {bubbles: true, cancelable: true}))
textarea.dispatchEvent(new KeyboardEvent('keydown', {bubbles: true, cancelable: true, keyCode: 35}))
// テンプレートを読み込む
$('#text-input').load(templateUrl, function (response, status, xhr) {
if (status == "success") {
try {
// 読み込んだテンプレートをテキストエリアにセット
textarea.value = /\.js$/.test(templateUrl) ? eval(response) : response
// テキストエリアのinputイベント
textarea.dispatchEvent(new InputEvent('input', {bubbles: true, cancelable: true}))
console.log("できました")
} catch (ex) {
console.log("だめでした>< \n" + ex)
}
} else {
console.log("だめでした>< \n" + status)
}
})
}
}
}
---.icon
バレットジャーナルkey
バレットジャーナルのkeyを呼び出せるメニューを追加
code:script.js
const STAMPS = [
{ title: '⬜ TODO', text: '⬜' },
{ title: '✅ タスク完了', text: '✅' },
{ title: '✨ TOBEリスト', text: '✨' },
{ title: '🔜 先送り', text: '🔜' },
{ title: '📅 リスケ済', text: '📅' },
null,
{ title: '💡 ひらめき', text: '💡' },
{ title: '🔍️ 疑問・調べること', text: '🔍️' },
{ title: '🚩 イベント', text: '🚩イベント ' },
{ title: '⭐ 重要', text: '⭐重要 ' },
null,
{ title: '💖 感謝', text: '💖感謝 ' },
{ title: '👍 good', text: '👍good ' },
{ title: '😞 bad', text: '😞bad ' },
{ title: '😋 美味しかった', text: '😋美味しかった ' },
];
function insertStamp(text) {
const lines = scrapbox.Page.lines;
if (!lines) return;
const lineIndex = scrapbox.Page.cursor?.line ?? lines.length - 1;
const charIndex = scrapbox.Page.cursor?.char ?? 0;
const currentText = lineslineIndex?.text ?? '';
// カーソル位置に絵文字を挿入
const newText = currentText.slice(0, charIndex) + text + currentText.slice(charIndex);
if (typeof cosense !== 'undefined') {
cosense.Page.updateLine(newText, lineIndex);
} else {
scrapbox.Page.updateLine(newText, lineIndex);
}
}
scrapbox.PageMenu.addMenu({
title: 'KEY',
image: 'https://i.gyazo.com/8149d2001d5eec0252fc4c85cf94f4dd.png',
});
for (const item of STAMPS) {
if (item === null) {
scrapbox.PageMenu('KEY').addSeparator();
} else {
scrapbox.PageMenu('KEY').addItem({
title: item.title,
onClick: () => insertStamp(item.text),
});
}
}
---.icon