Scrapboxプロジェクトの直径
日記ページを除外したい
code:script.js
(async () => {
const rawPages = [];
let followingId = null;
do {
const param = followingId === null ? '' : ?followingId=${followingId};
const res = await fetch(
https://scrapbox.io/api/pages/${scrapbox.Project.name}/search/titles${param}
);
followingId = res.headers.get('X-Following-Id');
rawPages.push(...(await res.json()));
} while (followingId);
let diameter = 0;
let diameterList;
for (const p in links) {
let visited = new Set();
let distList = [], p;
let depth = 0;
while (1) {
const nextList = [];
if (linksl === undefined) { return;
}
if (!visited.has(l)) {
visited.add(l);
const newPred = pred.slice();
newPred.push(p);
}
});
});
if (nextList.length == 0) {
break;
}
distList = nextList;
depth++;
}
const newDist = depth - 1;
if (newDist > diameter) {
diameter = newDist;
diameterList = [...distList00, distList01]; }
}
const win = $(`<div class="page">
<a>
<i class="kamon kamon-cross" style="position: absolute; right: 1em;"></i>
</a>
Diameter path:
<ol>
</ol>
</div>`)
.css({
'position': 'fixed',
'z-index': 1000,
'width': '40%',
'height': 'calc(98% - 140px)',
'top': '140px',
'right': '0',
'margin': '0 6%',
'padding': '1em',
'overflow-y': 'scroll',
'border': '1px solid rgba(0,0,0,0.16)',
});
$('> a:nth(0)', win).click(() => { win.hide('fast', () => win.remove()); });
const ol = $('ol', win);
for (const p of diameterList) {
const li = $('<li><a/></li>');
$('a', li)
.text(p)
.attr('href', /${scrapbox.Project.name}/${encodeURIComponent(p)});
ol.append(li);
}
$('body').append(win);
})();
public.icon