1
|
/**
|
2
|
* SPDX-License-Identifier: CC0-1.0
|
3
|
*
|
4
|
* View OpenCores projects list without nonfree js
|
5
|
*
|
6
|
* Copyright (C) 2021 Wojtek Kosior <koszko@koszko.org>
|
7
|
*
|
8
|
* This program is free software: you can redistribute it and/or modify
|
9
|
* it under the terms of the CC0 1.0 Universal License as published by
|
10
|
* the Creative Commons Corporation.
|
11
|
*
|
12
|
* This program is distributed in the hope that it will be useful,
|
13
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
* CC0 1.0 Universal License for more details.
|
16
|
*/
|
17
|
|
18
|
/* use with https://opencores.org/projects */
|
19
|
|
20
|
let data = JSON.parse(document.getElementById("__NEXT_DATA__").textContent);
|
21
|
let sections = {};
|
22
|
for (let h1 of document.getElementsByClassName("cMJCrc")) {
|
23
|
let ul = document.createElement("ul");
|
24
|
if (h1.nextElementSibling !== null)
|
25
|
h1.parentNode.insertBefore(ul, h1.nextElementSibling);
|
26
|
else
|
27
|
h1.parentNode.appendChild(ul);
|
28
|
|
29
|
sections[h1.children[1].firstChild.textContent] = ul;
|
30
|
}
|
31
|
|
32
|
for (let prop of data.props.pageProps.list) {
|
33
|
let ul = sections[prop.category];
|
34
|
if (ul === undefined) {
|
35
|
console.log(`unknown category "${prop.category}" for project "${prop.title}"`);
|
36
|
continue;
|
37
|
}
|
38
|
|
39
|
let li = document.createElement("li");
|
40
|
let a = document.createElement("a");
|
41
|
a.setAttribute("href", "/projects/" + prop.slug);
|
42
|
a.textContent = prop.title;
|
43
|
|
44
|
li.appendChild(a);
|
45
|
ul.appendChild(li);
|
46
|
}
|