8/32にサムネをつける活動
from 2023/09/02
8/32にサムネをつける活動
やれやれ。しょうがないなあtakker.icon
ここを押して生成されたコードを開発コンソールに貼り付けて実行する
code:addThumbnail.ts
import { patch } from "https://raw.githubusercontent.com/takker99/scrapbox-userscript-std/0.24.1/browser/websocket/mod.ts";
await patch(
"villagepump",
"2023/08/32\0\0",
(lines) => [
...lines.map((line) => line.text),
"https://gyazo.com/98e97040a8be73e69b2f7fa72f877720",
],
);
(以下、chromeでやっていた時のログ。途中でfirefoxだと↑を実行できることに気づいた)
おいちょっとまてまじかこいつ
https://gyazo.com/22ae3af599daa0f118faba05c7e4a05b
❌\0\0ではなく\0\0\0に治す
正しいタイトル名にしても同じエラーが出た
❌リネーム前のタイトル2023/08/32を指定
新しいページができただけでした。おわり
UserScriptでも直せないとなると……これはまずいな……
他の方法
(放棄)page idを使って、直接ScrapboxのWebSocketに編集リクエストを送る
特徴
page idなら、タイトルを使わずにアクセス可能
scrapbox-userscript-std/browser/websocketに頼らずにリクエストを送る必要がある
編集コマンドを組み立てるのがめんどい
実装
各種パラメタはベタ打ちする
2023/08/32\0\0\0のpage idは64f0e218eacf1b001c1044fa
project idは5e2455255664e000177a46fc
user idはtakker.iconのを使う
他に実行したい人がいれば、各自のuser idに差し替えてください
ページ本文はapi/page-data/export/:projectname.jsonから取得
2023/08/32\0\0\0の本文を取得できるAPIは現状これしかない
admin持っててよかった~
code:addThumbnail-v2.ts
import { Socket, socketIO, wrap } from "https://raw.githubusercontent.com/takker99/scrapbox-userscript-std/0.24.1/deps/socket.ts";
import { pushCommit } from "https://raw.githubusercontent.com/takker99/scrapbox-userscript-std/0.24.1/browser/websocket/_fetch.ts";
import { connect, disconnect } from "https://raw.githubusercontent.com/takker99/scrapbox-userscript-std/0.24.1/browser/websocket/socket.ts";
import { makeChanges } from "https://raw.githubusercontent.com/takker99/scrapbox-userscript-std/0.24.1/browser/websocket/makeChanges.ts";
import { HeadData, pull } from "https://raw.githubusercontent.com/takker99/scrapbox-userscript-std/0.24.1/browser/websocket/pull.ts";
import type { Line } from "https://raw.githubusercontent.com/takker99/scrapbox-userscript-std/0.24.1/deps/scrapbox-rest.ts";
const socket = await socketIO();
await connect(socket);
try {
const { request } = wrap(socket);
const userId = "5ef2bdebb60650001e1280f0";
const head = {
lines: ["2023/08/32\u0000\u0000\u0000","第35週: 日月火水木金土","2023年 66.85%経過","","今日のn年前"," 2022/08/32"," 2021/08/32","","biwa.icon"," 少し早く起きてしまった(4:00)"," 鳥の詩を聞いている"," iosからなら辿り着けるページ","","nishio.icon"," うーうー","","Mijinko_SD.icon","\tFirefoxからならアクセスできる","","nishio.icon"," PCで開くとギョッとする🤯","","","2023/08/31←2023/08/32→???",""],
commitId: ,
};
const newLines = update(head.lines, head);
const changes = [
...makeChanges(head.lines, newLines, { userId, head }),
];
await pushCommit(request, changes, {
parentId: head.commitId,
projectId: "5e2455255664e000177a46fc",
pageId: "64f0e218eacf1b001c1044fa",
userId,
});
} finally {
await disconnect(socket);
}
export dataから本文を抽出したところで、"\t[Firefox]からならアクセスできる"という情報を知る
ほんとだ、firefoxからならアクセスできるじゃんtakker.icon
scriptいらなくなっちゃった
✅完了
https://gyazo.com/a101358373110ee6ff97de53188c5320
何が完了したのかしばらくわからなかったが「誰かいいサムネを頼む、バタリ」を「8/32の日記にサムネイルを追加して」と解釈されてた、ウケるnishio.icon
あっ…yosider.icon
えっ違ったの?そんなーtakker.icon
勝手に勘違いしてプログラム書いちゃう恥ずかしいやつをやってしまった
「やつ」というほどよくあるシチュエーションではない気がする()yosider.icon
業務でコード書いてる人だとありそう?takker.icon
先回りしてコードを書いたつもりが、結局全然使わなかったとか
それはそれとして、酷いコミュニケーションミスをやらかした恐れがあるので、再発防止も兼ねて分析した
どうして「誰かいいサムネを頼む、バタリ」を「8/32の日記にサムネイルを追加して」と解釈したのか
自分も8/32かと思ってたはるひ.iconyosider.iconSummer498.icon
あっしも切れ者.icon