for-any-project
全てのScrapbox projectで使うtakker.icon用UserScript/UserCSSのbuild URL
2022-01-15
13:23:11 minifyだけにした
sourcemapがなくても、コードの形から大体どのあたりの処理なのか検討がつく
というかそんなにsourcemapでコードを閲覧する機会がない
13:21:01 やめた
minifyして行数を減らさないとダメそう
13:15:44 bundleだけにした
minifyコード+sourcemapよりbundleだけのほうがファイルサイズが若干小さくなる
code:template(txt)
for-any-project-min
code:script.js
code:takker-memex.js
code:tex-worker.js
code:esbuild-worker.js
code:takker-project.css
code:takker-user.css
code:takker-memex.css
code:takker-private.css
code:script.ts
import { sync } from "../scrapbox-watchlist-sync/script.ts";
sync({ project: "takker-dist" });
code:script.ts
import "../Open_Gyazo_page_menu/script.js";
code:script.ts
import { setup as setupSearch } from "../takker99%2Fscrapbox-incremental-fulltext-search/mod.tsx";
setupSearch().then((ops) => {
scrapbox.PageMenu.addItem({
title: "Fulltext Search",
onClick: () => {
ops.toggle();
},
});
});
code:script.ts
import { scrapBindings } from "./bindings.ts";
export { scrapBindings };
code:bindings.ts
import { Mousetrap } from "../takker99%2FScrapBindings/mod.ts";
import {
useStatusBar,
addTextInputEventListener,
removeTextInputEventListener,
} from "../scrapbox-userscript-std/dom.ts";
import { config, task } from "../takker99%2FScrapBindings-settings/config.ts";
import { Scrapbox } from "../scrapbox-jp%2Ftypes/userscript.ts";
declare const scrapbox: Scrapbox;
const { render } = useStatusBar();
let animationId: number| undefined;
const onSequenceUpdate = (text: string) => {
if(animationId !== undefined) cancelAnimationFrame(animationId);
animationId = requestAnimationFrame(() => render(
{ type: "text", text, }
));
};
export const scrapBindings = new Mousetrap(
{
addEventListener: addTextInputEventListener,
removeEventListener: removeTextInputEventListener,
},
{
onSequenceUpdate,
},
);
const errors = scrapBindings.bind({
...config,
...(scrapbox.Project.name === "takker-memex" ? task : {}),
});
if(errors.size > 0) {
messages.map((message) => - ${message}).join("\n")
}`
).join("\n"));
}
2023-07-10
2023-02-10
05:47:18 mobileでのhover待機時間を0.5秒から0.3秒に縮めた
操作はややトリッキー
単に離すとクリックになってしまう
2021-12-22
06:20:39 tampermonkeyから使うコードと共通化した
bundleしなきゃ使えないんだった
関連する分野を探せるようにするのが目的
code:script.ts
import "./scrapBubble.ts";
code:scrapBubble.ts
import { mount } from "../takker99%2FScrapBubble/mod.tsx";
import { Scrapbox } from "../scrapbox-jp%2Ftypes/userscript.ts";
declare const scrapbox: Scrapbox;
const additional_list= [];
switch (scrapbox.Project.name) {
case "hub":
case "villagepump":
case "verbalizing-community":
additional_list.push("villagepump", "hub", "verbalizing-community");
break;
case "programming-notes":
case "customize":
case "scrapboxlab":
additional_list.push("programming-notes", "customize", "scrapboxlab");
break;
case "sta":
additional_list.push("sta-taskmanagement");
break;
case "sta-taskmanagement":
case "taskmanagement":
additional_list.push("sta-taskmanagement", "taskmanagement");
break;
case "plurality-japanese":
additional_list.push("nishio", "tkgshn");
break;
}
mount({
//expired: 10 /*60秒は長いので10秒にした*/,
delay: /mobile/i.test(navigator.userAgent) ? 300 : 500,
code:scrapBubble.ts
style: '@import "/api/code/takker/kakeruの背景を白にするUserCSS/style.css";\n@import "/api/code/takker/アイコン記法を画像記法っぽくするUserCSS/style2.css";',
});
code:script.ts
import {
setup as setupJupyter
} from "../@takker%2FScrapJupyter/mod.ts";
import { findLatestCache, saveApiCache } from "../scrapbox-userscript-std/dom.ts";
// v0.24.0
const WORKER_URL = "/api/code/takker-dist/for-any-project-min/esbuild-worker.js";
(async () => {
const req = new Request(WASM_URL);
let res = await findLatestCache(req);
if (!res) {
res = await fetch(req);
await saveApiCache(req, res);
}
await setupJupyter(
await WebAssembly.compileStreaming(res),
WORKER_URL,
);
})();
code:script.ts
import { setup as setupSelectSuggestion } from "../選択範囲に似ているリンクを入力補完するUserScript/mod.tsx";
import { addTextInputEventListener } from "../scrapbox-userscript-std/dom.ts";
import { Scrapbox } from "../scrapbox-jp%2Ftypes/userscript.ts";
declare const scrapbox: Scrapbox;
(async () => {
const projects = [
scrapbox.Project.name,
"takker", "takker-memex", "takker-books", "takker-private",
"villagepump", "hub", "arpla",
"unnamedcamp", "unnamed-project",
"nishio", "enchi", "rashitamemo", "motoso",
"shokai", "masui", "rakusai", "yuiseki", "akiroom",
"c4j", "miyamonz", "mrsekut-p", "masuilab",
"kidaaam-92022284", "nwtgck", "juneboku",
"marshmallow-rm", "sushitecture", "sno2wman", "inteltank",
"issac-37765679", "blu3mo", "yosider", "Mijinko", "Mijinko-other",
"scrapbox-drinkup", "nota-techconf",
"customize", "scrapboxlab", "scrasobox", "programming-notes",
"tus-alpine", "tus-alpine-private",
"guiland",
];
const ops = await setupSelectSuggestion({
projects,
mark: {
...Object.fromEntries(
[
].map((p, t) => [p, https://scrapbox.io/api/pages/${p}/${t}/icon]) ),
"NDLSH-SB": "📚",
"plurality-japanese": "⿻",
},
enableSelfProjectOnStart: true,
});
const pvsp = (e: Event): void => {
e.preventDefault();
e.stopPropagation();
};
const hasPopup = (): boolean => document.querySelector(".line .popup-menu") !== null;
scrapBindings.bind({
"<Tab>": (e) => { if(hasPopup()) return; if(!ops.selectNext?.({ cyclic: true })) return; pvsp(e); },
"<S-Tab>": (e) => { if(hasPopup()) return; if(!ops.selectPrev?.({ cyclic: true })) return; pvsp(e); },
"<Enter>": (e) => { if(hasPopup()) return; if(!ops.confirm?.()) return; pvsp(e); },
"<Esc>": (e) => { if(hasPopup()) return; if(!ops.cancel?.()) return; pvsp(e); },
});
})();
code:script.ts
import { setup as setUpRun, previewSVG, previewGLSL, previewPlantUML, previewTikZ } from "../ScrapRun/mod.ts";
setUpRun({ previewers: [
{ when: /(?:^|\.)svg$/, preview: previewSVG },
{ when: /(?:^|\.)glsl$/, preview: previewGLSL },
{ when: /(?:^|\.)(?:plantuml|puml|pu)$/, preview: previewPlantUML },
{ when: /(?:^|\.)tikz\(tex\)$/, preview: previewTikZ(
"/api/code/takker-dist/for-any-project-min/tex-worker.js",
) },
]});
code:script.ts.disabled(ts)
(async () => {
const { toggle } = await setupSlider([]);
scrapbox.PageMenu.addItem({
title: "履歴スライダー",
onClick: toggle,
});
})();
code:script.ts
import { isMobile } from "../mobile版scrapboxの判定/script.js";
2023-04-30 18:08:18 全然使っていないのになぜか裏で動いていて怖いので外した
メモリをバカ食いしているのは、もしかしたらこいつかも
code:script.js.disabled
import { setup as setup2 } from "../scrapbox-local-graph/mod.tsx";
// 現状だとmobileでクラッシュする
if (!/mobile/i.test(navigator.userAgent)) {
const { open, close, isOpen } = setup2(
document.documentElement.dataset?.projectTheme?.includes?.("dark")
|| scrapbox.Project.name === "takker"
: ""
);
close();
scrapbox.PageMenu.addItem({
title: "toggle Local Graph",
onClick: () => { isOpen() ? close(): open(); },
});
}
code:script.ts
import "../popup/script.ts";
code:script.ts
import { main } from "../takker99%2Ftakker-scheduler/auto-review.ts";
main(
"takker",
);
code:script.ts
import { addButton } from "../Porterっぽい編集バーを生やすUserScript@1.0.0/mod.ts";
import {
porterCopy, porterCut, porterPaste, toggleCaret
} from "../Porterっぽい編集バーを生やすUserScript@1.0.0/commands.ts";
import {
downBlocks,
downLines,
indentBlocks,
indentLines,
insertText,
outdentBlocks,
outdentLines,
upBlocks,
upLines,
redo,
undo,
} from "../scrapbox-userscript-std/dom.ts";
if (isMobile()) {
addButton({
display: { type: "caret-left" },
onClick: ({ cursor, selection }) => {
cursor.focus();
selection.getSelectedText() === "" ? outdentBlocks() : outdentLines();
},
});
addButton({
display: { type: "caret-right" },
onClick: ({ cursor, selection }) => {
cursor.focus();
selection.getSelectedText() === "" ? indentBlocks() : indentLines();
},
});
addButton({
display: { type: "caret-up" },
onClick: ({ cursor, selection }) => {
cursor.focus();
selection.getSelectedText() === "" ? upBlocks() : upLines();
},
});
addButton({
display: { type: "caret-down" },
onClick: ({ cursor, selection }) => {
cursor.focus();
selection.getSelectedText() === "" ? downBlocks() : downLines()
},
});
addButton({
display: { type: "copy" },
onClick: async ({ cursor, selection }) => await porterCopy(cursor, selection),
});
addButton({
display: { type: "cut" },
onClick: async ({ cursor, selection }) => await porterCut(cursor, selection),
});
addButton({
display: { type: "clipboard" },
onClick: async ({ cursor }) => await porterPaste(cursor),
});
(revert)popup menuのいくつかのコマンドを持ってくる code:script.ts.disabled
addButton({
display: ({ selection }) => selection.hasSelection() ?
{ type: "unlink" } :
"",
onClick: async ({ selection }) => {
const text = selection.getSelectedText();
const unlinked = text.split("\n")
.map(line => line.replace(
"$1"
))
.join("\n");
if (text === unlinked) return;
await insertText(unlinked);
},
});
code:script.ts.disabled
addButton({
display: ({ selection }) => selection.hasSelection() ?
{ type: "strikethrough" } :
"",
onClick: async ({ selection }) => {
const text = selection.getSelectedText();
const striked = strike(text);
if (text === striked) return;
await insertText(striked);
},
});
文字装飾
code
code:script.ts.disabled
addButton({
display: ({ selection }) => selection.hasSingleLineSelection() ?
{ type: "code" } :
"",
onClick: async ({ selection }) => {
const text = selection.getSelectedText();
await insertText(\`${text}\`);
},
});
code:script.ts.disabled
addButton({
display: ({ selection }) => hasURL(selection.getSelectedText()) ? "URL" : "",
onClick: async ({ selection }) => {
const text = selection.getSelectedText();
const converted = await convertURL(text);
if (text === converted) return;
await insertText(converted);
},
});
code:script.ts.disabled
addButton({
display: ({ selection }) => getLink(selection.getSelectedText()) ? "update a link" : "",
onClick: async ({ selection }) => {
const text = selection.getSelectedText();
await replace(
text,
);
},
});
入れる候補
google検索
ndl検索
OALD検索
文字装飾
code:script.ts
addButton({
display: { type: "undo" },
onClick: () => undo(),
});
addButton({
display: { type: "redo" },
onClick: () => redo(),
});
addButton({
display: ({ cursor }) => cursor.getVisible() && cursor.hasFocus
// @ts-ignore private扱いだけど、これしかアクセス方法がないため使わせていただく
&& cursor.visiblePopupMenu ?
{ type: "i-cursor" },
onClick: ({ cursor }) => toggleCaret(cursor),
});
}
code:script.ts
import "../scrapbox-editor-begin-edit/script.ts";
code:script.ts
import "../mobileからtimestampを行頭に挿入するUserScript/script.js";
code:script.ts
import "../Kakeruを開くPage_Menu/script.js";
一部のコマンドははどのprojectでも使えるようにする
code:script.ts
import {
transport, createTask,
} from "../takker99%2Ftakker-scheduler/deps.ts";
if (isMobile() && scrapbox.Project.name !== "takker-memex") {
const id = "task";
scrapbox.PageMenu.addMenu({
title: id,
});
scrapbox.PageMenu(id).addItem({
title: 'Book starting',
onClick: createTask,
});
scrapbox.PageMenu(id).addItem({
title: 'Transport',
onClick: () => transport({
from: {
project: scrapbox.Project.name,
title: scrapbox.Page.title!,
},
to: "takker-memex",
}),
});
}
その他script
code:script.ts
import { makeNewPage } from "../custom-new-page/mod.ts";
import {
newPageHook,
splittedLinkHook,
taskLineHook,
} from "../for-custom-new-page/mod.ts";
if (isMobile()) {
const id = "New Page";
scrapbox.PageMenu.addMenu({
title: id,
});
scrapbox.PageMenu(id).addItem({
title: "New Page",
onClick: () => {
const project = window.prompt("Create a new page at", scrapbox.Project.name);
if (!project) return;
makeNewPage({ project, mode: "noopen", hooks })?.();
},
});
scrapbox.PageMenu(id).addItem({
title: "New Page and Open",
onClick: () => {
const project = window.prompt("Create a new page at", scrapbox.Project.name);
if (!project) return;
makeNewPage({ project, mode: "self", hooks })?.();
},
});
}
import "../ページを転送するUserScript/pageMenu.ts";
import { addToInboxFromPrompt } from "../Inboxに素早く入れるUserScript/mod.ts";
scrapbox.PageMenu.addMenu({
title: "Add to inbox",
onClick: () => addToInboxFromPrompt(
"takker-memex",
"メモ帳",
),
});
import "../scrapbox-icon-button/script.js";
import "../Markdown形式でページのURLをコピーするPageMenu/script.js";
code:script.ts
import {
setup as setupActions
} from "../takker99%2Ftakker-scheduler/viewer.tsx";
import {
setup as setupScheduler,
setupWedget
} from "../takker99%2Ftakker-scheduler/weekly-scheduler.tsx";
(async () => {
const id = "next-action";
const selector = head style[data-userscript-name="${id}"];
document.querySelector(selector)?.remove?.();
const style = document.createElement("style");
style.dataset.userscriptName = id;
style.textContent = `
position: absolute;
font: 900 20px/46px "Font Awesome 5 Free";
}
button#${id}.tool-btn::before {
content: "\\f0ae";
}
button#scheduler.tool-btn::before {
content: "\\f073";
font-weight: 400;
}
opacity: 0;
}`;
document.head.append(style);
const { open } = await setupActions(projects);
scrapbox.PageMenu.addMenu({
title: id,
image: "/assets/img/favicon/apple-touch-icon.png",
onClick: open,
});
const scheduler = await setupScheduler(projects);
scrapbox.PageMenu.addMenu({
title: "scheduler",
image: "/assets/img/favicon/apple-touch-icon.png",
onClick: scheduler.open,
});
{
const key = "takker-scheduler/wedget";
let settings = JSON.parse(localStorage.getItem(key) ?? "{}");
const project = scrapbox.Project.name;
const wedget = await setupWedget(projects, settingsproject); const toggle = () => {
if (wedget.isOpen) { wedget.close(); } else { wedget.open?.(); }
localStorage.setItem(key, JSON.stringify(settings));
};
if (!isMobile()) {
scrapbox.PageMenu.addItem({
title: "toggle wedget",
onClick: toggle,
});
} else {
addButton({
display: { type: "calendar" },
onClick: toggle,
});
}
}
})();
2023-10-16 15:47:16 ボタン削減のため一旦外す
re-export
個別のprojectごとにさらにカスタマイズしたいときに使う
code:script.ts
export { addButton, insertText, };
import map
通信内容を見る限りだと、読み込めているんだけどな……
16:56:05 最新版に差し替えたら直った
code:import_map.json
{
"imports": {
"jsr:@cosense/std@0.28/browser/dom": "jsr:@cosense/std@0.29/browser/dom",
"jsr:@cosense/std@0.28/parseAbsoluteLink": "jsr:@cosense/std@0.29/parseAbsoluteLink",
"jsr:@cosense/std@0.28/rest": "jsr:@cosense/std@0.29/rest",
"jsr:@luca/esbuild-deno-loader@0.11": "jsr:@luca/esbuild-deno-loader@0.10",
"npm:option-t@50/plain_result": "npm:option-t@49/plain_result"
},
"compilerOptions": {
"lib": [
"esnext",
"dom",
"dom.iterable",
"deno.ns"
],
"jsx": "react-jsx",
"jsxImportSource": "npm:preact@10"
}
}
差し替え用
code:parser.ts
code:date-fns.ts
import { lightFormat } from "../date-fns/mod.ts";
export const format = lightFormat;
export * from "../date-fns/mod.ts";
code:lightFormat.ts
import { lightFormat } from "../date-fns/mod.ts";
export { lightFormat as default };
全然使っていない
多分このせいで他のUserScriptの読み込みがblockingされてしまっていた
#2022-11-29 11:43:50 s/addToInboxFromSelection/addToInboxFromPrompt 全く使っていない