46 Zeilen
1.2 KiB
TypeScript
46 Zeilen
1.2 KiB
TypeScript
import {trie} from "./thalia_lib.ts"
|
|
|
|
function titel(book: HTMLElement) {
|
|
return book.getElementsByClassName(
|
|
"element-text-standard-black tm-artikeldetails__titel",
|
|
)[0].innerHTML.toLowerCase();
|
|
}
|
|
|
|
function clean() {
|
|
const books: HTMLCollectionOf<HTMLElement> = document.getElementsByClassName(
|
|
"tm-produktliste__eintrag artikel",
|
|
);
|
|
const not_found: string[] = [];
|
|
let removed = 0;
|
|
for (const book of books) {
|
|
if (book === null) continue;
|
|
if (book.style.display == "none") {
|
|
continue;
|
|
}
|
|
if (trie.startsWith(titel(book))) {
|
|
book.style.display = "none";
|
|
removed += 1;
|
|
} else not_found.push(titel(book));
|
|
}
|
|
const artikel = document.getElementsByClassName("sichtbare-artikel");
|
|
if (artikel.length != 0) {
|
|
artikel[0].innerHTML = not_found.length.toString();
|
|
}
|
|
console.debug(artikel);
|
|
console.debug("titel nicht in der blacklist:", not_found);
|
|
}
|
|
|
|
async function run() {
|
|
GM_registerMenuCommand("Clean results", function (event: Event) {
|
|
console.debug(event);
|
|
event.preventDefault();
|
|
clean();
|
|
}, "c");
|
|
const button = document.getElementsByTagName("suche-button-mehr-laden");
|
|
if (button.length != 0) {
|
|
for (let i = 0; i < 10; i++) await button[0].load();
|
|
}
|
|
clean();
|
|
}
|
|
run();
|