Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/js/common/sites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,39 @@ const sites: SiteConfig[] = [
url.pathname.includes('page-scan')),
getPageImageURL: (url) => url.toString(),
},
{
// TODO: implement the cross-browser thingy that also does hot reload, so it's not a fkin pain in the ass to develop on
// TODO: autosave pages in the right order, since there's a way to identify the page number from the URL
// TODO: improve the preview display of the pages in the popup
// Reader page https://r3.vlebooks.com/Reader?ean=9781844456994
// includes a series of images like https://r3.vlebooks.com/reader?handler=PageImage&ean=9781844456994&pagenumber=1&imageWidth=1000
// the reader is a scrollable container with page-ID'd elements
// and the page images are loaded when you scroll to the page
// <div id="page12" class="pdfscrollablepage grabable" data-pg="12" style="height: 1008px; width: 704.298px;"><table class="pageLoadContainer" style="width:704px; height:1008px"><tbody><tr><td>1 What do we mean by youth work?<br>p1</td></tr></tbody></table><figure id="figsvg-12" class="figsvg"><svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 487 697" preserveAspectRatio="xMinYMin meet" id="svg-12"><image class="pdfpageimage" width="487" height="697" xlink:href="/reader?handler=PageImage&amp;ean=9781844456994&amp;pagenumber=12&amp;imageWidth=1000" href="/reader?handler=PageImage&amp;ean=9781844456994&amp;pagenumber=12&amp;imageWidth=1000"></image><g id="pageannotations12"><svg id="bookmark-12" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" width="40" height="100" x="467" preserveAspectRatio="none" class="pagebookmark " style="display: none;"><path d="M0 512V48C0 21.49 21.49 0 48 0h288c26.51 0 48 21.49 48 48v464L192 400 0 512z"></path></svg></g><g id="pageTextBoxes12"></g></svg></figure></div>
name: 'VLEBooks',
chromeURLScope: '*://r3.vlebooks.com/',
host: 'r3.vlebooks.com',
readerDomain: {
urlContains: 'r3.vlebooks.com/Reader?ean=',
},
constructBookURL: (_url) => {
return _url.toString();
},
pageResourceURLFilter: '*://*.vlebooks.com/*',
testPageImageURL: (_, url) => {
return (
url.pathname.includes('/reader') &&
url.searchParams.has('handler') &&
url.searchParams.get('handler') === 'PageImage' &&
url.searchParams.has('ean') &&
url.searchParams.has('pagenumber') &&
url.searchParams.has('imageWidth')
);
},
getPageImageURL: (url) => {
return url.toString();
},
},
];

export default sites;
1 change: 0 additions & 1 deletion src/js/eventPage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ chrome.webRequest.onCompleted.addListener(
if (!pageImageURL) {
return;
}
console.log('Page image URL: ', pageImageURL);
savePage(pageImageURL).catch((e) => {
console.error('Error saving page image:', e);
});
Expand Down
24 changes: 14 additions & 10 deletions src/js/popup/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Box, VStack, HStack, Text, Button, Heading } from '@chakra-ui/react';
import type { FC } from 'react';
import { useState, useEffect, useRef } from 'react';

import sites from '../common/sites';
import { getURL, getBookURL, getBook } from '../common/utils';
import type { Book, ScraperMessage, ClearBook, UpdatePageOrder, SaveBook } from '../types';

Expand Down Expand Up @@ -160,7 +161,8 @@ export const Popup: FC = () => {
console.log('Rendering popup with book:', book);

// Filter out only actual image pages for display
const imagePages = book?.pages?.filter((url) => url.includes('/docImage.action') && url.includes('encrypted=')) || [];
// TODO: this is a site-specific filter, move this to the site config for the ProQuest config
// const imagePages = book?.pages?.filter((url) => url.includes('/docImage.action') && url.includes('encrypted=')) || [];

return (
<Box
Expand All @@ -185,9 +187,9 @@ export const Popup: FC = () => {
<Text fontSize="md" fontWeight="bold" color="gray.800">
Total captures: {book.pages?.length || 0}
</Text>
<Text fontSize="sm" color="gray.600">
{/* <Text fontSize="sm" color="gray.600">
Valid images: {imagePages.length}
</Text>
</Text> */}
<Text>
Use in a fullscreen window with pages zoomed for best quality.{' '}
<a
Expand All @@ -207,13 +209,13 @@ export const Popup: FC = () => {
colorPalette="blue"
size="md"
flex={1}
disabled={imagePages.length === 0}
// disabled={imagePages.length === 0}
bg="blue.500"
color="white"
_hover={{ bg: 'blue.600' }}
_disabled={{ bg: 'gray.300', color: 'gray.500' }}
>
Download PDF ({imagePages.length} images)
Download PDF ({book.pages?.length || 0} images)
</Button>
<ResetButton reset={() => void reset()}>Reset</ResetButton>
</HStack>
Expand All @@ -222,7 +224,7 @@ export const Popup: FC = () => {
Show captured pages
</Checkbox>

{imagePages.length > 0 && (
{book.pages?.length && book.pages.length > 0 && (
<Box width="100%" mt={4}>
<Text fontSize="sm" fontWeight="medium">
Progress: {progress}%
Expand Down Expand Up @@ -261,7 +263,7 @@ export const Popup: FC = () => {
{displayPages && (
<Box width="100%">
<Text fontSize="sm" color="gray.700" mb={2} fontWeight="medium">
Image Pages ({imagePages.length}):
Image Pages ({book.pages?.length || 0}):
</Text>
<VStack
gap={2}
Expand All @@ -274,13 +276,15 @@ export const Popup: FC = () => {
p={2}
bg="gray.50"
>
{imagePages.map((url, index) => (
{book.pages?.map((url, index) => (
<Page
key={url}
url={url}
index={index}
moveUp={index > 0 ? () => updatePageOrder(index, index - 1) : undefined}
moveDown={index < imagePages.length - 1 ? () => updatePageOrder(index, index + 1) : undefined}
moveDown={
index < (book.pages?.length || 0) - 1 ? () => updatePageOrder(index, index + 1) : undefined
}
deletePage={() => void deletePage(index)}
/>
))}
Expand All @@ -291,7 +295,7 @@ export const Popup: FC = () => {
) : (
<VStack gap={3} textAlign="center" py={8}>
<Text fontSize="xl" color="gray.600">
Navigate to a ProQuest ebook
Navigate to a supported ebook reader. {sites.map((site) => site.name).join(', ')}
</Text>
<Text fontSize="sm" color="gray.500">
Start reading pages to begin capturing images
Expand Down