mirror of
https://github.com/alexadam/save-as-ebook.git
synced 2025-09-10 17:34:47 +00:00
check if iframe content exists before replacing it
This commit is contained in:
parent
ab229d926e
commit
6b4268f5b0
2 changed files with 12 additions and 32 deletions
|
@ -27,25 +27,6 @@ chrome.runtime.onInstalled.addListener(details => {
|
||||||
///////////////////
|
///////////////////
|
||||||
///////////////////
|
///////////////////
|
||||||
|
|
||||||
|
|
||||||
// chrome.tabs.onUpdated.addListener(function (tabId, changeInfo, tab) {
|
|
||||||
// if (changeInfo.status == 'complete' && tab.active) {
|
|
||||||
|
|
||||||
// chrome.tabs.executeScript(null, {file: 'jquery.js'});
|
|
||||||
// chrome.tabs.executeScript(null, {file: 'jszip.js'});
|
|
||||||
// chrome.tabs.executeScript(null, {file: 'jszip-utils.js'});
|
|
||||||
// chrome.tabs.executeScript(null, {file: 'pure-parser.js'});
|
|
||||||
// chrome.tabs.executeScript(null, {file: 'cssjson.js'});
|
|
||||||
// chrome.tabs.executeScript(null, {file: 'filesaver.js'});
|
|
||||||
// chrome.tabs.executeScript(null, {file: 'saveEbook.js'});
|
|
||||||
// chrome.tabs.executeScript(null, {file: 'extractHtml.js'});
|
|
||||||
// chrome.tabs.executeScript(null, {file: 'utils.js'});
|
|
||||||
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var isBusy = false;
|
var isBusy = false;
|
||||||
var busyResetTimer = null
|
var busyResetTimer = null
|
||||||
|
|
||||||
|
@ -320,23 +301,17 @@ function applyAction(tab, action, justAddToBuffer, includeStyle, appliedStyles,
|
||||||
|
|
||||||
if (!response) {
|
if (!response) {
|
||||||
resetBusy()
|
resetBusy()
|
||||||
chrome.tabs.sendMessage(tab[0].id, {'alert': 'Save as eBook does not work on this web site!'}, (r) => {
|
chrome.tabs.sendMessage(tab[0].id, {'alert': 'Save as eBook does not work on this web site!'}, (r) => {});
|
||||||
console.log(r);
|
|
||||||
});
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.content.trim() === '') {
|
if (response.content.trim() === '') {
|
||||||
if (justAddToBuffer) {
|
|
||||||
chrome.tabs.sendMessage(tab[0].id, {'alert': 'Cannot add an empty selection as chapter!'}, (r) => {
|
|
||||||
console.log(r);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
chrome.tabs.sendMessage(tab[0].id, {'alert': 'Cannot generate the eBook from an empty selection!'}, (r) => {
|
|
||||||
console.log(r);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
resetBusy()
|
resetBusy()
|
||||||
|
if (justAddToBuffer) {
|
||||||
|
chrome.tabs.sendMessage(tab[0].id, {'alert': 'Cannot add an empty selection as chapter!'}, (r) => {});
|
||||||
|
} else {
|
||||||
|
chrome.tabs.sendMessage(tab[0].id, {'alert': 'Cannot generate the eBook from an empty selection!'}, (r) => {});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!justAddToBuffer) {
|
if (!justAddToBuffer) {
|
||||||
|
@ -356,11 +331,13 @@ function applyAction(tab, action, justAddToBuffer, includeStyle, appliedStyles,
|
||||||
}
|
}
|
||||||
|
|
||||||
function resetBusy() {
|
function resetBusy() {
|
||||||
|
isBusy = false
|
||||||
|
|
||||||
if (busyResetTimer) {
|
if (busyResetTimer) {
|
||||||
clearTimeout(busyResetTimer)
|
clearTimeout(busyResetTimer)
|
||||||
busyResetTimer = null
|
busyResetTimer = null
|
||||||
}
|
}
|
||||||
isBusy = false
|
|
||||||
chrome.browserAction.setBadgeText({text: ""})
|
chrome.browserAction.setBadgeText({text: ""})
|
||||||
|
|
||||||
let popups = chrome.extension.getViews({type: "popup"});
|
let popups = chrome.extension.getViews({type: "popup"});
|
||||||
|
|
|
@ -122,6 +122,9 @@ function extractIFrames() {
|
||||||
let changeIFrames = []
|
let changeIFrames = []
|
||||||
let newDivs = []
|
let newDivs = []
|
||||||
for (let iFrame of allIframes) {
|
for (let iFrame of allIframes) {
|
||||||
|
if (!iFrame.contentDocument || !iFrame.contentDocument.body) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
let bodyContent = iFrame.contentDocument.body.innerHTML
|
let bodyContent = iFrame.contentDocument.body.innerHTML
|
||||||
let bbox = iFrame.getBoundingClientRect()
|
let bbox = iFrame.getBoundingClientRect()
|
||||||
let newDiv = document.createElement('div')
|
let newDiv = document.createElement('div')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue