mirror of
https://github.com/alexadam/save-as-ebook.git
synced 2025-09-10 17:34:47 +00:00
fix wrong ebook name if page has no title
This commit is contained in:
parent
f9e615501d
commit
79609be75d
1 changed files with 7 additions and 3 deletions
|
@ -241,7 +241,10 @@ function getPageUrl(url) {
|
||||||
return url.toLowerCase().replace(/\s+/g,'_').replace(/[^a-z0-9_]/g,'') + Math.floor(Math.random() * 10000) + '.xhtml';
|
return url.toLowerCase().replace(/\s+/g,'_').replace(/[^a-z0-9_]/g,'') + Math.floor(Math.random() * 10000) + '.xhtml';
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPageTitle(title) { //TODO
|
function getPageTitle(title) {
|
||||||
|
if (title.trim().length === 0) {
|
||||||
|
return 'ebook';
|
||||||
|
}
|
||||||
return title;
|
return title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,9 +312,10 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
||||||
});
|
});
|
||||||
|
|
||||||
$.when.apply($, imgsPromises).done(function() {
|
$.when.apply($, imgsPromises).done(function() {
|
||||||
|
var tmpTitle = getPageTitle(document.title);
|
||||||
result = {
|
result = {
|
||||||
url: getPageUrl(document.title),
|
url: getPageUrl(tmpTitle),
|
||||||
title: getPageTitle(document.title),
|
title: tmpTitle,
|
||||||
baseUrl: getCurrentUrl(),
|
baseUrl: getCurrentUrl(),
|
||||||
images: extractedImages,
|
images: extractedImages,
|
||||||
content: tmpContent
|
content: tmpContent
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue