mirror of
https://github.com/alexadam/save-as-ebook.git
synced 2025-09-10 17:34:47 +00:00
add support for base64 imgs; don't execute extract scripts multiple times on the same tab
This commit is contained in:
parent
cc68e99a94
commit
0124977a37
3 changed files with 111 additions and 53 deletions
|
@ -25,8 +25,6 @@ document.getElementById("editChapters").onclick = function() {
|
|||
|
||||
window.close();
|
||||
});
|
||||
|
||||
|
||||
};
|
||||
|
||||
function dispatch(action, justAddToBuffer) {
|
||||
|
@ -37,34 +35,45 @@ function dispatch(action, justAddToBuffer) {
|
|||
currentWindow: true,
|
||||
active: true
|
||||
}, function(tab) {
|
||||
chrome.tabs.sendMessage(tab[0].id, {
|
||||
type: 'echo'
|
||||
}, function(response) {
|
||||
if (!response) {
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/jquery.js'});
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/utils.js'});
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/filesaver.js'});
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/jszip.js'});
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/jszip-utils.js'});
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/pure-parser.js'});
|
||||
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/jquery.js'});
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/utils.js'});
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/filesaver.js'});
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/jszip.js'});
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/jszip-utils.js'});
|
||||
chrome.tabs.executeScript(tab[0].id, {file: '/pure-parser.js'});
|
||||
|
||||
chrome.tabs.executeScript(tab[0].id, {
|
||||
file: 'extractHtml.js'
|
||||
}, function() {
|
||||
chrome.tabs.sendMessage(tab[0].id, {
|
||||
type: action
|
||||
}, function(response) {
|
||||
if (!justAddToBuffer) {
|
||||
buildEbook([response]);
|
||||
} else {
|
||||
getEbookPages(function (allPages) {
|
||||
allPages.push(response);
|
||||
saveEbookPages(allPages);
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
chrome.tabs.executeScript(tab[0].id, {
|
||||
file: 'extractHtml.js'
|
||||
}, function() {
|
||||
sendMessage(tab[0].id, action, justAddToBuffer);
|
||||
});
|
||||
} else if (response.echo) {
|
||||
sendMessage(tab[0].id, action, justAddToBuffer);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function sendMessage(tabId, action, justAddToBuffer) {
|
||||
chrome.tabs.sendMessage(tabId, {
|
||||
type: action
|
||||
}, function(response) {
|
||||
if (!justAddToBuffer) {
|
||||
buildEbook([response]);
|
||||
} else {
|
||||
getEbookPages(function (allPages) {
|
||||
allPages.push(response);
|
||||
saveEbookPages(allPages);
|
||||
window.close();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.getElementById('savePage').onclick = function() {
|
||||
dispatch('extract-page', false);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue