diff --git a/resources/scraper.js b/resources/scraper.js index 4637f45521..dcf4ebfe8c 100644 --- a/resources/scraper.js +++ b/resources/scraper.js @@ -21,7 +21,7 @@ send_msg({type: 'print', text: text}); } - if (!document.location.href.startsWith('chrome-error:') && !document.location.href.startsWith('about:')) { - send_msg({type: 'domready', html: new XMLSerializer().serializeToString(document)}); + if (document.location && document.location.href && !document.location.href.startsWith('chrome-error:') && !document.location.href.startsWith('about:')) { + send_msg({type: 'domready', url: document.location.href, html: new XMLSerializer().serializeToString(document)}); } })(); diff --git a/src/calibre/scraper/simple_backend.py b/src/calibre/scraper/simple_backend.py index 7dfad9ec2b..3d393eb837 100644 --- a/src/calibre/scraper/simple_backend.py +++ b/src/calibre/scraper/simple_backend.py @@ -16,7 +16,9 @@ from calibre.gui2.webengine import create_script, insert_scripts def canonicalize_qurl(qurl): - qurl = qurl.adjusted(QUrl.UrlFormattingOption.StripTrailingSlash | QUrl.UrlFormattingOption.NormalizePathSegments) + qurl = qurl.adjusted( + QUrl.UrlFormattingOption.StripTrailingSlash | QUrl.UrlFormattingOption.NormalizePathSegments | QUrl.UrlFormattingOption.RemoveFragment + ) if qurl.path() == '/': qurl = qurl.adjusted(QUrl.UrlFormattingOption.RemovePath) return qurl