Skip to content

Instantly share code, notes, and snippets.

@sk22
Last active September 20, 2019 12:00
Show Gist options
  • Save sk22/dabddad4af91154c55795568833ef984 to your computer and use it in GitHub Desktop.
Save sk22/dabddad4af91154c55795568833ef984 to your computer and use it in GitHub Desktop.
## CONFIG
# number of pages
pages=10
# book id, as in the url (part between `/ebook/` and `/index.html`)
# (note that this is usually just one number, but it can also be muliple, like below)
book=2366/1
# paste your cookie (from your logged in browser page) between the two single quotes below
cookie=''
basefolder=a.digi4school.at/ebook/$book
baseurl=https://$basefolder
echo book $book, $pages pages
echo
## DOWNLOAD PAGES
echo Press return to start the download.
read
for i in $(seq 1 $pages); do
wget --recursive --header="Cookie: $cookie" $baseurl/$i/$i.svg
done
echo
echo Done downloading the pages.
## DOWNLOAD IMAGES
echo Press return download the embedded images.
read
for i in $(seq 1 $pages); do
cat $basefolder/$i/$i.svg |
grep -oP 'xlink:href="\K(.*?)\.png(?=")' |
for f in $(</dev/stdin); do
wget --recursive --header="Cookie: $cookie" $baseurl/$i/$f;
done
done
echo
echo Done downloading the images.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Spurensuche</title>
<style>
:root {
/* EDIT THOSE */
--height: 1125px;
--width: 822px;
}
body {
text-align: center;
}
#wrapper {
text-align: left;
display: inline-block;
margin: 0 auto;
}
#page {
border: none;
width: var(--width);
height: var(--height);
pointer-events: none;
}
#left, #right {
position: absolute;
width: 20%;
height: var(--height);
}
#left { left: 0; }
#right { right: 0; }
</style>
</head>
<body>
<div id="left"></div>
<div id="right"></div>
<div id="wrapper">
<iframe id="page"></iframe><br>
<input type="number" id="number">
</div>
<script>
// EDIT THIS:
const book = '1303'
let i = Number(location.hash.slice(1)) || 1
const pageElement = document.getElementById('page')
const numberElement = document.getElementById('number')
const left = document.getElementById('left')
const right = document.getElementById('right')
left.addEventListener('click', previousPage)
right.addEventListener('click', nextPage)
numberElement.addEventListener('change', e => {
const value = e.target.value
const num = Number(value)
if (num) {
i = num
loadPage(num)
}
})
async function loadPage(i) {
location.hash = `#${i}`
pageElement.src = `./a.digi4school.at/ebook/${book}/${i}/${i}.svg`
numberElement.value = i
}
function nextPage() {
loadPage(++i)
}
function previousPage() {
if (i > 1) loadPage(--i)
}
loadPage(i)
function keyDownHandler (e) {
const RIGHT = 39
const LEFT = 37
if (![RIGHT, LEFT].includes(e.keyCode)) return
switch (e.keyCode) {
case RIGHT: nextPage(); break
case LEFT: previousPage(); break
}
}
document.addEventListener('keydown', keyDownHandler)
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment