fkd
https://scrapbox.io/files/63b9367efbe5fc001eefab2a.JPG
Account
Twitter:@fkd_hideaway
GitHub:@fukada6280
深層学習など中心に勉強しています
国内と国外で査読有 発表経験あり
研究では企業連携のグループで学生側のリーダーをしています
UserScript
/teamlab-frontend/マーカーをつけるUserCSS
/nishio/Scrapbox振り返り機能
/shokai/ページの1部分を別のページに切り出すUserScript
公式の機能になったのでUserScriptに載せる必要がなくなった。
code:script.js
// 選択した文字列にマーカー
scrapbox.PopupMenu.addButton({
title: 'マーカー',
onClick: text => [[${text}]]
})
// 選択した文字列でコード化
scrapbox.PopupMenu.addButton({
title: '\code\',
onClick: text => \`${text}\`
})
// 過去のページを見る機能
const LINE_PER_SECTION = 3;
const day = 60 * 60 * 24 * 1000;
const year = day * 365;
const project_name = scrapbox.Project.name;
const project_root = https://scrapbox.io/${project_name};
const menu_title = "振り返り";
const make_title = () => ${strftime(new Date())}${menu_title};
// score: 0 is best
const sections = [
{
title: "50日前",
score: (diff) => Math.abs(diff - 50 * day),
},
{
title: "1年前",
score: (diff) => Math.abs(diff - year),
},
{
title: "n年前",
score: (diff) => {
// excludes 1年前
if (diff < year * 1.5) {
return year;
}
const mod = diff % year;
return Math.min(mod, year - mod);
},
},
];
const main = () => {
// calc scores
const now = Date.now();
const scored_pages = [];
scrapbox.Project.pages.forEach((page) => {
const updated = page.updated;
if (updated === 0) return;
const diff = now - updated * 1000;
const p = { ...page };
sections.forEach((sction) => {
psction.title = sction.score(diff);
});
scored_pages.push(p);
});
// generate page contents
const lines = [];
sections.forEach((section) => {
scored_pages.sort((a, b) => asection.title - bsection.title);
lines.push(section.title);
scored_pages.slice(0, LINE_PER_SECTION).forEach((page) => {
const title = page"title";
const date = strftime(new Date(page.updated * 1000));
lines.push( ${date} [${title}]);
});
lines.push("");
});
create_page(make_title(), lines);
};
function create_page(title, lines) {
const body = encodeURIComponent(lines.join("\n"));
window.open(${project_root}/${title}?body=${body});
}
function pad(number) {
if (number < 10) {
return "0" + number;
}
return number;
}
function strftime(d) {
return (
d.getUTCFullYear() +
"-" +
pad(d.getUTCMonth() + 1) +
"-" +
pad(d.getUTCDate())
);
}
const WAIT = { title: "Please wait...", image: null, onClick: () => null };
const onClick = () => {
scrapbox.PageMenu(menu_title).addItem(WAIT);
main();
scrapbox.PageMenu(menu_title).removeAllItems();
};
scrapbox.PageMenu.addMenu({
title: menu_title,
image: "https://gyazo.com/11140c8b35b407c5d490a94ec6f2528f/raw",
onClick,
});