ページタイトルに絵文字を入れて状態管理する
Scrapboxのタイトルに絵文字を入れて状況表示に使ったりはしてます

なるほど

ですです。

先頭に絵文字を入れておくと、タスクの状況が一番左に整列して気持ちいいです

なるほど

当時は記事タイトルじゃなくてリストに絵文字を置いてる
ワンクリックで書けたりしたらよさそうですけどね~
タイトルで発動するUserScriptを作れば行けそうですね
全然テストしていませんが、多分これで動くと思います

2021-03-11 21:17:26 テストしました。動作確認取れました
以下のコードを自分のページか開発コンソールに貼り付けて実行すると動きます
jsimport('/api/code/nota-techconf/ページタイトルに絵文字を入れて状態管理する/script.js');
ページを開いている状態で Ctrl+p
を押すとタイトルに絵文字が挿入されます
連打で変化します
switch
の case
を増やせば、いろんな絵文字に対応できると思います
本文にカーソルがなくても動きます
バグだらけで1日放置してしまってすみません……
script.jsimport {press} from '/api/code/programming-notes/scrapbox-keyboard-emulation/script.js';
import {goHeadLine} from '/api/code/takker/scrapbox-cursor-emulation/cursor.js';
let repeat = false;
document.addEventListener('keyup', e => {
const {ctrlKey, key} = e;
if (key !== 'p' || !ctrlKey) return;
e.preventDefault();
e.stopPropagation();
repeat = false;
});
document.addEventListener('keydown', e => {
const {ctrlKey, key} = e;
if (key !== 'p' || !ctrlKey) return;
e.preventDefault();
e.stopPropagation();
if (repeat) return;
goHeadLine();
(async () => {
await sleep(100);
// scrapbox.Page.titleへの反映までにタイムラグがある
// 代わりにDOMから取得する
const icon = document.getElementsByClassName('lines')[0]
.firstElementChild.textContent[0];
switch (icon) {
case '⬜':
press('Delete');
insertText(`✅`);
break;
case '✅':
press('Delete');
insertText(`⬜`);
break;
default:
insertText(`⬜`);
break;
}
})();
repeat = true;
});
const sleep = milliseconds => new Promise(resolve => setTimeout(resolve, milliseconds));
function insertText(text) {
const cursor = document.getElementById('text-input');
cursor.focus();
cursor.value = text;
const uiEvent = document.createEvent('UIEvent');
uiEvent.initEvent('input', true, false);
cursor.dispatchEvent(uiEvent);
}
一体誰なんだろうな~(すっとぼけ)
