Use dom instead of document

I should probably write a tslint rule for this.
feature-show_image_resolution
neobooru 2019-08-05 02:00:54 +02:00
parent 199bb0f37d
commit b5745e1be5
1 changed files with 3 additions and 3 deletions

View File

@ -14,7 +14,7 @@ export default class Moebooru implements ILoader {
post.source = dom.location.href; post.source = dom.location.href;
// Set image url // Set image url
const originalImageElement = document.querySelector("#highres") as HTMLAnchorElement; const originalImageElement = dom.querySelector("#highres") as HTMLAnchorElement;
if (originalImageElement) { if (originalImageElement) {
post.imageUrl = originalImageElement.href; post.imageUrl = originalImageElement.href;
} }
@ -22,7 +22,7 @@ export default class Moebooru implements ILoader {
// Set safety // Set safety
// Same method as Gelbooru but cleaner code // Same method as Gelbooru but cleaner code
const safetyExp = new RegExp("Rating: (.*)"); const safetyExp = new RegExp("Rating: (.*)");
const safetyElements = Array.from(document.querySelectorAll("#stats > ul > li")) const safetyElements = Array.from(dom.querySelectorAll("#stats > ul > li"))
.map(x => x as HTMLLIElement) .map(x => x as HTMLLIElement)
.filter(x => x.innerText.startsWith("Rating:")); .filter(x => x.innerText.startsWith("Rating:"));
@ -62,7 +62,7 @@ export default class Moebooru implements ILoader {
let category: SzuruCategory | undefined; let category: SzuruCategory | undefined;
// Loop over all classes because some sites (konachan) // Loop over all classes because some sites (konachan)
// have mutliple classes, e.g. "tag-link tag-type-copyright" // have mutliple classes, e.g. "tag-link tag-type-copyright"
for (const className of Array.from(el.classList)) { for (const className of Array.from(el.classList)) {
switch (className) { switch (className) {