for-any-project
全てのScrapbox projectでdefaultで用いるtakker.icon用UserScript
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@
code:script.js
//@ts-check
import { sync } from "../scrapbox-watchlist-sync/script.ts";
sync({ project: "takker-dist" });
code:script.js
import "../Open_Gyazo_page_menu/script.js";
code:script.js
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.js
import { scrapBindings } from "../ScrapBindings/script.js";
import { config } from "../ScrapBindings-settings/config.js";
scrapBindings.push(...config);
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.js
import "./scrapBubble.js";
code:scrapBubble.js
import { mount } from "../takker99%2FScrapBubble/mod.tsx";
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;
}
mount({
//expired: 10 /*60秒は長いので10秒にした*/,
delay: /mobile/i.test(navigator.userAgent) ? 300 : 500,
code:scrapBubble.js
style: '@import "/api/code/takker/kakeruの背景を白にするUserCSS/style.css";\n@import "/api/code/takker/アイコン記法を画像記法っぽくするUserCSS/style2.css";',
});
code:script.js
import {
setup as setupJupyter
(async () => {
const req = new Request(WASM_URL);
let res = await findLatestCache(req);
if (!res) {
res = await fetch(req);
await saveCache(req, res);
}
await setupJupyter(
// 0.19.2
await WebAssembly.compileStreaming(res),
WORKER_URL,
);
})();
code:script.js
import { setup as setupSelectSuggestion } from "../選択範囲に似ているリンクを入力補完するUserScript/mod.tsx";
(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", "june29",
"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": "📚",
},
enableSelfProjectOnStart: true,
});
document.getElementById("text-input").addEventListener("keydown", (e) => {
if (e.ctrlKey || e.metaKey || e.altKey) return;
const hasPopup = document.querySelector(".line .popup-menu") !== null;
if (hasPopup && e.key !== "Escape") return;
switch (e.key) {
case "Tab": {
const executed = e.shiftKey ?
ops.selectPrev({ cyclic: true }) :
ops.selectNext({ cyclic: true });
if (!executed) return;
break;
}
case "Enter": {
if (e.shiftKey) return;
if (!ops.confirm()) return;
break;
}
case "Escape" : {
if (e.shiftKey) return;
if (!ops.cancel()) return;
break;
}
default:
return;
}
e.preventDefault();
e.stopPropagation();
});
})();
code:script.js
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(
) },
]});
code:script.js
(async () => {
const { toggle } = await setupSlider();
scrapbox.PageMenu.addItem({
title: "履歴スライダー",
onClick: toggle,
});
})();
code:script.js
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.js
import {
popupBindings
} from "../Popup_Menuに独自のkeyboard_shortcutを割り当てるUserScript/script.js";
popupBindings.start();
popupBindings.push(
{ key: "-", buttonName: "\uf0cc" }, // 複数行打ち消し線
{ key: "]", buttonName: "\uf127" }, // リンクを外す
{ key: "c", buttonName: "Copy plain" },
{ key: "4", buttonName: "fx" }, // 数式記法にする
);
code:script.js
import "../popup/script.ts";
code:script.js
import { main } from "../takker99%2Ftakker-scheduler/auto-review.ts";
main(
"takker",
);
code:script.js
import "../現在時刻をbarで視覚的に表示するUserScript/script.ts";
code:script.js
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.js.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.js.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.js.disabled
addButton({
display: ({ selection }) => selection.hasSingleLineSelection() ?
{ type: "code" } :
"",
onClick: async ({ selection }) => {
const text = selection.getSelectedText();
await insertText(\`${text}\`);
},
});
code:script.js.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.js.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.js
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.js
import "../scrapbox-editor-begin-edit/script.ts";
code:script.js
import "../mobileからtimestampを行頭に挿入するUserScript/script.js";
code:script.js
import "../Kakeruを開くPage_Menu/script.js";
一部のコマンドははどのprojectでも使えるようにする
code:script.js
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.js
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.js
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 { toggle } = await setupActions(projects);
scrapbox.PageMenu.addMenu({
title: id,
image: "/assets/img/favicon/apple-touch-icon.png",
onClick: toggle,
});
const scheduler = await setupScheduler(projects);
scrapbox.PageMenu.addMenu({
title: "scheduler",
image: "/assets/img/favicon/apple-touch-icon.png",
onClick: scheduler.toggle,
});
{
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 = () => {
wedget.toggle();
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 ボタン削減のため一旦外す
code:script.js
//import { initialize } from "../scrapbox-speech-input/script.js";
//initialize();
import { setup as execute } from "../IME_onの時、キー入力をScrapboxに渡すUserScript/script.ts";
execute();
タイムスタンプを消す
code:script.js
scrapbox.TimeStamp.removeAllFormats();
re-export
個別のprojectごとにさらにカスタマイズしたいときに使う
code:script.js
export { addButton, insertText, popupBindings, scrapBindings };
import map
通信内容を見る限りだと、読み込めているんだけどな……
16:56:05 最新版に差し替えたら直った
code:import_map.json
{
"imports": {
}
}
差し替え用
code:parser.ts
code:date-fns.ts
import { lightFormat } from "../date-fns/mod.ts";
export const format = lightFormat;
export * from "../date-fns/mod.ts";
全然使っていない
多分このせいで他のUserScriptの読み込みがblockingされてしまっていた
#2022-11-29 11:43:50 s/addToInboxFromSelection/addToInboxFromPrompt 全く使っていない