Skip to content
Open
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
7 changes: 6 additions & 1 deletion AutoPatchWork.safariextension/includes/AutoPatchWork.js
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@
append_point.insertBefore(root, insert_point);
var docHeight = documentHeight();
var docs = get_next_elements(htmlDoc);
var elementHeight = pageElementHeight(docs[docs.length - 1]);
var first = docs[0];
if (!first) {
dispatch_event('AutoPatchWork.terminated', {message: 'The next page\'s pageElement was empty.'});
Expand All @@ -699,7 +700,7 @@
docs[i] = insert_node;
});
if (status.bottom) status.bottom.style.height = Root.scrollHeight + 'px';
if (docHeight === documentHeight()) {
if (elementHeight === pageElementHeight(docs[docs.length - 1]) && docHeight === documentHeight()) {
return dispatch_event('AutoPatchWork.error', {message: 'missing next page contents'});
}
next = get_next(htmlDoc);
Expand All @@ -724,6 +725,10 @@
function documentHeight() {
return Math.max(document.documentElement.scrollHeight, document.body.scrollHeight)
}

function pageElementHeight(element) {
return element.parentNode.scrollHeight;
}

function createXHTML(str) {
return new DOMParser().parseFromString(str, 'application/xhtml+xml');
Expand Down