diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2026-05-24 20:16:56 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2026-05-24 20:16:56 +0300 |
| commit | a578fa50b2fc2d11ff5a0d45c2cd4d390409739a (patch) | |
| tree | fa502e64c2afdf90063a53d82bd9d3c80d0616af /src/reader.js | |
| parent | 9942c9e5c5863fd66c945ec96125779cd382d611 (diff) | |
| download | the-epube-a578fa50b2fc2d11ff5a0d45c2cd4d390409739a.tar.gz the-epube-a578fa50b2fc2d11ff5a0d45c2cd4d390409739a.tar.xz | |
deal with remaining tsc errors
Diffstat (limited to 'src/reader.js')
| -rw-r--r-- | src/reader.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/reader.js b/src/reader.js index 3340203..aa9f103 100644 --- a/src/reader.js +++ b/src/reader.js @@ -498,7 +498,8 @@ class ReaderClass extends AppCommon { // get our stuff from resource loader and inject into iframe content - const base_url = window.location.href.match(/^.*\//)[0]; + const match = window.location.href.match(/^.*\//); + const base_url = match ? match[0] : window.location.href; $(contents.document.head) .append($("<style type='text/css'>") @@ -1186,8 +1187,9 @@ class ReaderClass extends AppCommon { if (typeof EpubeApp != "undefined") { window.setTimeout(function() { - const bg_color = window.getComputedStyle(document.querySelector("body"), null) - .getPropertyValue("background-color"); + const body = document.querySelector("body"); + const bg_color = body ? window.getComputedStyle(body, null) + .getPropertyValue("background-color") : ""; let match = bg_color.match(/rgb\((\d{1,}), (\d{1,}), (\d{1,})\)/); @@ -1197,8 +1199,9 @@ class ReaderClass extends AppCommon { EpubeApp.setStatusBarColor(parseInt(match[1]), parseInt(match[2]), parseInt(match[3])); } - const accent_color = window.getComputedStyle(document.querySelector(".header .title"), null) - .getPropertyValue("color"); + const title = document.querySelector(".header .title"); + const accent_color = title ? window.getComputedStyle(title, null) + .getPropertyValue("color") : ""; match = accent_color.match(/rgb\((\d{1,}), (\d{1,}), (\d{1,})\)/); @@ -1260,7 +1263,10 @@ class ReaderClass extends AppCommon { if (this.book && this.book.rendition) this.book.rendition.getContents().forEach((rendition) => { - width += parseInt(rendition.window.getComputedStyle(rendition.document.querySelector('body')).getPropertyValue('padding-left')); + const body = rendition.document.querySelector('body'); + + if (body) + width += parseInt(rendition.window.getComputedStyle(body).getPropertyValue('padding-left')); }); console.log(`resizing side columns to ${width} px`); |
