Skip to content

Commit 5c1b256

Browse files
committed
feat hypothes.is and title injection
1 parent 2578158 commit 5c1b256

File tree

4 files changed

+47
-2
lines changed

4 files changed

+47
-2
lines changed

README.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,18 @@
22

33
This cloud-based epub reader allow hypothes.is browser extension (chrome on pc, kiwibroswer on android, resp.) to be run for particular uploaded epub book.
44

5-
[Try it](https://structseeker.github.io/hypothes.is-epubjs-reader/)!
5+
Read your epub file using the top-right upload button, the file is not transmitted to any remote server.
6+
7+
[Try it](https://structseeker.github.io/hypothes.is-epubjs-reader/)!
8+
9+
10+
11+
## Features
12+
13+
Embedded Hypothes.is: Usable on any broweser-support device.
14+
More Readable Title: the epub title is injected before the page title, making it more viewable in your profile.
15+
Fix upstream UI Bugs.
16+
17+
**Caution:** Be sure that epub is safe and contain no malicious script!
18+
19+
Todo: fix the security flaw.

dist/index.html

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,24 @@
2424
import { Reader } from "./js/epubreader.min.js"
2525
const url = new URL(window.location)
2626
const path = url.searchParams.get("bookPath") || "https://s3.amazonaws.com/moby-dick/"
27-
window.onload = (e) => new Reader(path)
27+
//window.onload = (e) => new Reader(path)
28+
window.onload = (e) => {
29+
let reader = new Reader(path);
30+
31+
document.body.addEventListener("load", function(e) {
32+
if(e.target.tagName == 'IFRAME'){
33+
let iframedoc = e.target.contentWindow.document
34+
iframedoc.querySelector('title').prepend(document.querySelector('title').innerHTML);
35+
}
36+
}, true // use capture
37+
)
38+
39+
return reader;
40+
}
2841
</script>
42+
43+
<script src="https://hypothes.is/embed.js" async></script>
44+
2945
</head>
3046

3147
<body>

note.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Modify Title
2+
3+
```
4+
let iframe = document.querySelector('.epub-view > iframe')
5+
let iframedoc = iframe.contentWindow.document
6+
7+
iframe.onload = () => {
8+
iframedoc.querySelector('title').prepend(document.querySelector('title').innerHTML);
9+
}
10+
11+
```
12+

src/reader.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ export class Reader {
7676
minSpreadWidth: this.settings.spread.min,
7777
width: "100%",
7878

79+
//script:"https://hypothes.is/embed.js",
7980
allowScriptedContent: true,
81+
// allowSameOrigin: false,
82+
// should be set false, but the option is not yet available.
8083

8184
height: "100%",
8285
snap: true

0 commit comments

Comments
 (0)