diff --git a/src/js/common/sites.ts b/src/js/common/sites.ts index 239041e..c22b124 100644 --- a/src/js/common/sites.ts +++ b/src/js/common/sites.ts @@ -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 + //
1 What do we mean by youth work?
p1
+ 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; diff --git a/src/js/eventPage/index.ts b/src/js/eventPage/index.ts index 10a846a..c993fdf 100644 --- a/src/js/eventPage/index.ts +++ b/src/js/eventPage/index.ts @@ -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); }); diff --git a/src/js/popup/Popup.tsx b/src/js/popup/Popup.tsx index f9a78e0..cc73850 100644 --- a/src/js/popup/Popup.tsx +++ b/src/js/popup/Popup.tsx @@ -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'; @@ -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 ( { Total captures: {book.pages?.length || 0} - + {/* Valid images: {imagePages.length} - + */} Use in a fullscreen window with pages zoomed for best quality.{' '} { 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) void reset()}>Reset @@ -222,7 +224,7 @@ export const Popup: FC = () => { Show captured pages - {imagePages.length > 0 && ( + {book.pages?.length && book.pages.length > 0 && ( Progress: {progress}% @@ -261,7 +263,7 @@ export const Popup: FC = () => { {displayPages && ( - Image Pages ({imagePages.length}): + Image Pages ({book.pages?.length || 0}): { p={2} bg="gray.50" > - {imagePages.map((url, index) => ( + {book.pages?.map((url, 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)} /> ))} @@ -291,7 +295,7 @@ export const Popup: FC = () => { ) : ( - Navigate to a ProQuest ebook + Navigate to a supported ebook reader. {sites.map((site) => site.name).join(', ')} Start reading pages to begin capturing images