mirror of
https://github.com/alexadam/save-as-ebook.git
synced 2025-09-11 01:44:44 +00:00
keep track of applied styles and add them if Include Style is not set
This commit is contained in:
parent
126ce6f039
commit
53620b6456
2 changed files with 18 additions and 8 deletions
|
@ -324,7 +324,7 @@ function jsonToCss(jsonObj) {
|
|||
return result;
|
||||
}
|
||||
|
||||
function extractCss(callback) {
|
||||
function extractCss(appliedStyles, callback) {
|
||||
getIncludeStyle(function (result) {
|
||||
if (result) {
|
||||
$('body').find('*').each(function (i, pre) {
|
||||
|
@ -358,6 +358,14 @@ function extractCss(callback) {
|
|||
});
|
||||
callback(jsonToCss(tmpIdsToNewCss));
|
||||
} else {
|
||||
var mergedCss = '';
|
||||
if (appliedStyles && appliedStyles.length > 0) {
|
||||
for (var i = 0; i < appliedStyles.length; i++) {
|
||||
mergedCss += appliedStyles[i].style;
|
||||
}
|
||||
callback(mergedCss);
|
||||
return;
|
||||
}
|
||||
callback();
|
||||
}
|
||||
});
|
||||
|
@ -388,8 +396,8 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
|||
var result = {};
|
||||
var pageSrc = '';
|
||||
var tmpContent = '';
|
||||
// var styleFile =
|
||||
extractCss(function (styleFile) {
|
||||
|
||||
extractCss(request.appliedStyles, function (styleFile) {
|
||||
if (request.type === 'extract-page') {
|
||||
pageSrc = document.getElementsByTagName('body')[0];
|
||||
tmpContent = getContent(pageSrc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue