From c772716e98e11181d301deadeca52856ac18f085 Mon Sep 17 00:00:00 2001 From: Feuerfuchs Date: Mon, 18 May 2020 18:51:19 +0200 Subject: Improved Gemini support --- js/main.ts | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'js') diff --git a/js/main.ts b/js/main.ts index 031e959..0c1d3de 100644 --- a/js/main.ts +++ b/js/main.ts @@ -246,10 +246,11 @@ function generateImageThumbnails() { const linkImgEl = linkImgEls[i] as HTMLAnchorElement; const thumbnailUrl = linkImgEl.href.replace(/^(.*?)\/I/, '$1/T'); - const lineBreakEl = document.createTextNode('\n'); + const sectionEl = document.createElement('div'); + sectionEl.classList.add('section'); const typeAnnotEl = document.createElement('span'); - typeAnnotEl.classList.add('type-annotation'); + typeAnnotEl.classList.add('section__type'); typeAnnotEl.textContent = ' -> '; const thumbnailEl = document.createElement('img'); @@ -259,6 +260,7 @@ function generateImageThumbnails() { }); const thumbnailAnchorEl = document.createElement('a'); + thumbnailAnchorEl.classList.add('section__content'); thumbnailAnchorEl.classList.add('img-preview'); thumbnailAnchorEl.href = linkImgEl.href; thumbnailAnchorEl.addEventListener('click', e => { @@ -278,9 +280,9 @@ function generateImageThumbnails() { }); thumbnailAnchorEl.append(thumbnailEl); - linkImgEl.parentNode!.insertBefore(thumbnailAnchorEl, linkImgEl.nextSibling); - linkImgEl.parentNode!.insertBefore(typeAnnotEl, thumbnailAnchorEl); - linkImgEl.parentNode!.insertBefore(lineBreakEl, typeAnnotEl); + sectionEl.append(typeAnnotEl); + sectionEl.append(thumbnailAnchorEl); + linkImgEl.parentNode!.parentNode!.insertBefore(sectionEl, linkImgEl.parentNode!.nextSibling); } } @@ -288,12 +290,7 @@ function removeImageThumbnails() { const linkImgEls = document.querySelectorAll('.link--IMG, .link--GIF'); let i = linkImgEls.length; while (i--) { - const linkImgEl = linkImgEls[i]; - let j = 3; - - while (j-- && linkImgEl.nextSibling) { - linkImgEl.nextSibling.remove(); - } + linkImgEls[i].parentNode!.nextSibling!.remove(); } } -- cgit v1.2.3-70-g09d2