Skip to content

Commit c5301e7

Browse files
committed
npm: gather analysis section
1 parent dd563d5 commit c5301e7

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

npmjs.com/index.js

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ document.head.appendChild(
3131
}),
3232
);
3333

34-
const repos = document.getElementById("repository");
34+
const sidebar = document.querySelector('[aria-label="Package sidebar"]');
3535

3636
const list = document.createElement("ul");
3737

@@ -49,9 +49,9 @@ function main() {
4949
const pkg = document.title.substring(0, document.title.length - 6);
5050

5151
const sites = [
52+
["npmgraph", `https://npmgraph.js.org/?q=${pkg}`],
5253
["Bundlephobia", `https://bundlephobia.com/package/${pkg}`],
5354
["anvaka", `https://npm.anvaka.com/#/view/2d/${pkg}`],
54-
["npmgraph", `https://npmgraph.js.org/?q=${pkg}`],
5555
["Packagephobia", `https://packagephobia.com/result?p=${pkg}`],
5656
["pkg-size.dev", `https://pkg-size.dev/${pkg}`],
5757
["npm-stat", `https://npm-stat.com/charts.html?package=${pkg}`],
@@ -63,9 +63,23 @@ function main() {
6363
list.append(listItem(label, site));
6464
}
6565

66-
repos.parentNode.append(list);
66+
sidebar.prepend(list);
67+
sidebar.prepend(
68+
Object.assign(document.createElement("h3"), {
69+
textContent: "Analyze",
70+
className: "c84e15be f5 mt2 pt2 mb0",
71+
}),
72+
);
6773
}
6874

69-
if (repos) {
75+
if (sidebar) {
76+
const checkers = ["https://bundlephobia.com/", "https://npmgraph.js.org/"];
77+
78+
for (const checker of checkers) {
79+
const link = document.querySelector(`[href^="${checker}"]`);
80+
if (link) {
81+
link.remove();
82+
}
83+
}
7084
main();
7185
}

0 commit comments

Comments
 (0)