mirror of
https://github.com/alexadam/save-as-ebook.git
synced 2025-09-11 09:54:41 +00:00
msic - problems
This commit is contained in:
parent
8147350ce8
commit
aee4df3cc6
4 changed files with 36 additions and 24 deletions
|
@ -26,11 +26,11 @@ function saveEbookPages(pages) {
|
|||
}
|
||||
|
||||
document.getElementById('savePage').onclick = function() {
|
||||
localStorage.removeItem('ebook');
|
||||
chrome.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
}, function(tab) {
|
||||
console.log('aiai');
|
||||
chrome.tabs.sendMessage(
|
||||
tab[0].id,
|
||||
{
|
||||
|
@ -47,6 +47,7 @@ document.getElementById('savePage').onclick = function() {
|
|||
};
|
||||
|
||||
document.getElementById('saveSelection').onclick = function() {
|
||||
localStorage.removeItem('ebook');
|
||||
chrome.tabs.query({
|
||||
currentWindow: true,
|
||||
active: true
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
var cssFileName = 'ebook.css';
|
||||
var pageName = 'ebook.xhtml';
|
||||
var ebookName = "ebook-" + document.title + ".epub";
|
||||
|
@ -19,6 +18,15 @@ function getEbookPages() {
|
|||
|
||||
}
|
||||
|
||||
function getImgDownloadUrl(baseUrl, imgSrc) {
|
||||
if (imgSrc.indexOf('http') !== 0) {
|
||||
console.log(baseUrl + '/' + imgSrc);
|
||||
return baseUrl + '/' + imgSrc;
|
||||
}
|
||||
console.log(imgSrc);
|
||||
return imgSrc;
|
||||
}
|
||||
|
||||
function getImagesIndex(allImgSrc) {
|
||||
return Object.keys(allImgSrc).reduce(function(prev, elem, index) {
|
||||
return prev + '\n' + '<item href="images/' + allImgSrc[elem] + '" id="img' + index + '" media-type="image/' + getFileExtension(elem) + '"/>';
|
||||
|
@ -199,7 +207,8 @@ function buildEbook() {
|
|||
var imgsPromises = [];
|
||||
allPages.forEach(function(page) {
|
||||
Object.keys(page.imgs).forEach(function(imgSrc, index) {
|
||||
var tmpDeffered = deferredAddZip(imgSrc, page.imgs[imgSrc], imgs);
|
||||
console.log('AICI', imgSrc, getImgDownloadUrl(page.baseUrl, imgSrc));
|
||||
var tmpDeffered = deferredAddZip(getImgDownloadUrl(page.baseUrl, imgSrc), page.imgs[imgSrc], imgs);
|
||||
imgsPromises.push(tmpDeffered);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -2,6 +2,15 @@ var allImgSrc = {};
|
|||
|
||||
//////
|
||||
|
||||
function getCurrentUrl() {
|
||||
var url = window.location.href;
|
||||
if (url.indexOf('?') > 0) {
|
||||
url = window.location.href.split('?')[0];
|
||||
}
|
||||
url = url.substring(0, url.lastIndexOf('/')+1);
|
||||
return url;
|
||||
}
|
||||
|
||||
function getFileExtension(fileName) {
|
||||
var tmpFileName = fileName.split('.').pop();
|
||||
if (tmpFileName.indexOf('?') > 0) {
|
||||
|
@ -76,7 +85,7 @@ function force(contentString) {
|
|||
|
||||
// https://github.com/blowsie/Pure-JavaScript-HTML5-Parser
|
||||
function sanitize(rawContentString) {
|
||||
|
||||
allImgSrc = {};
|
||||
var srcTxt = '';
|
||||
var dirty = null;
|
||||
try {
|
||||
|
@ -229,6 +238,7 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
|||
result = {
|
||||
url: getPageUrl(document.title),
|
||||
title: getPageTitle(document.title), //gatPageTitle(document.title),
|
||||
baseUrl: getCurrentUrl(),
|
||||
imgs: allImgSrc,
|
||||
content: getContent(pageSrc)
|
||||
};
|
||||
|
@ -237,6 +247,7 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
|||
result = {
|
||||
url: getPageUrl(document.title),
|
||||
title: getPageTitle(document.title),
|
||||
baseUrl: getCurrentUrl(),
|
||||
imgs: allImgSrc,
|
||||
content: getContent(pageSrc)
|
||||
};
|
||||
|
|
9
gigi.js
9
gigi.js
|
@ -1,9 +0,0 @@
|
|||
|
||||
|
||||
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
||||
if (request.type === 'get-title') {
|
||||
console.log("AAAAAAAA 2", document.title);
|
||||
sendResponse({title: document.title});
|
||||
return true;
|
||||
}
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue