From 7dd34efee5fcaf5f782e38299658e6a4209b1dfc Mon Sep 17 00:00:00 2001 From: alexadam Date: Sat, 11 Mar 2017 14:21:05 +0200 Subject: [PATCH 001/113] styles - wip --- web-extension/background.js | 26 +++ web-extension/cssEditor.css | 181 ++++++++++++++++++ web-extension/cssEditor.js | 356 +++++++++++++++++++++++++++++++++++ web-extension/cssjson.js | 297 +++++++++++++++++++++++++++++ web-extension/extractHtml.js | 151 +++++++++++---- web-extension/manifest.json | 2 +- web-extension/menu.html | 11 ++ web-extension/menu.js | 91 +++++++++ web-extension/saveEbook.js | 8 +- web-extension/utils.js | 34 ++++ 10 files changed, 1119 insertions(+), 38 deletions(-) create mode 100644 web-extension/cssEditor.css create mode 100644 web-extension/cssEditor.js create mode 100644 web-extension/cssjson.js diff --git a/web-extension/background.js b/web-extension/background.js index c1c75a1..9bdcd43 100644 --- a/web-extension/background.js +++ b/web-extension/background.js @@ -1,3 +1,5 @@ +// var GLOBAL_CURRENT_STYLE = null; + chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { if (request.type === 'get') { @@ -27,5 +29,29 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { if (request.type === 'set title') { chrome.storage.local.set({'title': request.title}); } + if (request.type === 'get styles') { + chrome.storage.local.get('styles', function (data) { + if (!data || !data.styles) { + sendResponse({styles: []}); + } else { + sendResponse({styles: data.styles}); + } + }); + } + if (request.type === 'set styles') { + chrome.storage.local.set({'styles': request.styles}); + } + if (request.type === 'get current style') { + chrome.storage.local.get('currentStyle', function (data) { + if (!data || !data.currentStyle) { + sendResponse({currentStyle: 0}); + } else { + sendResponse({currentStyle: data.currentStyle}); + } + }); + } + if (request.type === 'set current style') { + chrome.storage.local.set({'currentStyle': request.currentStyle}); + } return true; }); diff --git a/web-extension/cssEditor.css b/web-extension/cssEditor.css new file mode 100644 index 0000000..cd9f144 --- /dev/null +++ b/web-extension/cssEditor.css @@ -0,0 +1,181 @@ +body.dragging, body.dragging * { + cursor: move !important; +} +.dragged { + position: absolute; + opacity: 0.5; + z-index: 2000; +} +ul.cssEditor-chapters-list li.placeholder { + position: relative; + margin: 0; + padding: 0; + border: solid 10px #f5f5f5; +} + +#cssEditor-Title { + font-size: 20px; + font-weight: bold; + float: left; + display: inline-block; + font-family: "sans-serif"; +} + +#cssEditor-ebookTitleHolder { + background-color: #eee; + padding: 10px 20px; + margin-bottom: 10px; +} +#cssEditor-ebookTitleLabel { + font-weight: bold; + font-size: 18px; + font-family: sans-serif; + margin-right: 10px; +} +#cssEditor-ebookTitle { + padding: 5px; + font-size: 15px; + font-family: "sans-serif"; + width: 85%; +} +ul, ul.cssEditor-chapters-list { + width: 100%; + display: block; + padding: 0; + margin: 0; + list-style-type: none !important; +} +.cssEditor-chapter-item { + display: block; + line-height: 35px; + height: 35px; + padding: 5px 0; + vertical-align: middle; + font-size: 17px; + list-style-type: none; +} +.cssEditor-chapter-item:hover { + background-color: #f5f5f5; +} +.cssEditor-drag-handler { + cursor: move; + padding: 3px; + margin-right: 5px; + border-radius: 5px; +} +.cssEditor-chapter-item > input[type="text"] { + padding: 5px; + font-size: 15px; + font-family: "sans-serif"; + width: 80%; + border: none; + border-bottom: solid 1px #aaa; +} + +#cssEditor-modalHeader { + display: block; + overflow: hidden; + padding: 20px; +} +#cssEditor-modalList { + display: block; + /*width: 100%;*/ + /*border-top: solid 1px black;*/ + /*border-bottom: solid 1px black;*/ + padding: 20px; + padding-top: 0; +} +#cssEditor-modalFooter { + display: block; + overflow: hidden; +} +.chapter-item * { + vertical-align: middle; +} +#dragHandler { + padding: 0 5px; +} + + +.cssEditor-text-button { + border: none; + font-size: 15px; + font-family: "sans-serif"; + padding: 5px; + background-color: rgba(0, 0, 0, 0); + margin: 0 3px; + outline: none; + cursor: pointer; +} +.cssEditor-text-button:hover { + background-color: #000; + color: #fff; +} +.cssEditor-text-red { + color: red; +} + +.cssEditor-float-left { + float: left; +} +.cssEditor-float-right { + float: right; +} + +.cssEditor-footer-button { + padding: 18px 20px; + margin: 0; + font-size: 18px; + border: none; + background-color: rgba(0, 0, 0, 0); + display: inline-block; +} +.cssEditor-footer-button:hover { + color: white; + background-color: rgba(0, 0, 0, 1); + cursor: pointer; +} +.cssEditor-save-button { + background-color: yellow; +} +.cssEditor-cancel-button { + /*background-color: black;*/ +} + +@media (max-width: 1700px) { + .cssEditor-chapter-item { + line-height: 30px; + height: 30px; + padding: 4px 0; + font-size: 14px; + } + .cssEditor-chapter-item > input[type="text"] { + padding: 3px; + font-size: 12px; + width: 75%; + } + .cssEditor-text-button { + font-size: 12px; + padding: 3px; + margin: 0 2px; + } + .cssEditor-footer-button { + padding: 15px 20px; + margin: 0; + font-size: 15px; + border: none; + background-color: rgba(0, 0, 0, 0); + } +} + +@media (max-width: 1100px) { + .cssEditor-chapter-item { + line-height: 30px; + height: 60px; + padding: 4px 0; + font-size: 14px; + } + .cssEditor-chapter-item > input[type="text"] { + width: 90%; + } +} diff --git a/web-extension/cssEditor.js b/web-extension/cssEditor.js new file mode 100644 index 0000000..b81df89 --- /dev/null +++ b/web-extension/cssEditor.js @@ -0,0 +1,356 @@ +for (var i=0; i 0) { + allStyles = allStyles.slice(0, 0).concat(allStylesTmp); + } + + while (existingStyles.hasChildNodes() && existingStyles.childElementCount > 1) { + existingStyles.removeChild(existingStyles.lastChild); + } + + for (var i = 0; i < allStyles.length; i++) { + var listItem = document.createElement('option'); + listItem.id = 'option_' + i; + listItem.className = 'cssEditor-chapter-item'; + listItem.value = 'option_' + i; + listItem.innerText = allStyles[i].title; + if (currentStyle && (allStyles[i].title === currentStyle.title)) { + listItem.selected = 'selected'; + } + existingStyles.appendChild(listItem); + } + } + + function editCurrentStyle() { + if (!currentStyle) { + return; + } + + showStyleEditor(); + showRemoveStyle(); + + document.getElementById('cssEditor-styleName').value = currentStyle.title; + document.getElementById('cssEditor-matchUrl').value = currentStyle.url; + document.getElementById('cssEditor-styleContent').value = currentStyle.style; + + } + + function resetFields() { + document.getElementById('cssEditor-styleName').value = ''; + document.getElementById('cssEditor-matchUrl').value = ''; + document.getElementById('cssEditor-styleContent').value = ''; + } + + function hideStyleEditor() { + document.getElementById('cssEditor-styleEditor').style.display = 'none'; + } + + function showStyleEditor() { + document.getElementById('cssEditor-styleEditor').style.display = 'block'; + } + + function showRemoveStyle() { + document.getElementById('cssEditor-removeStyle').style.display = 'inline-block'; + } + + function hideRemoveStyle() { + document.getElementById('cssEditor-removeStyle').style.display = 'none'; + } + + function saveStyle() { + var tmpValue = { + title: document.getElementById('cssEditor-styleName').value, + url: document.getElementById('cssEditor-matchUrl').value, + style: document.getElementById('cssEditor-styleContent').value + } + if (currentStyle === null) { + allStyles.push(tmpValue); + currentStyle = tmpValue; + currentStyleIndex = allStyles.length - 1; + } else { + currentStyle = tmpValue; + allStyles[currentStyleIndex] = currentStyle; + } + setStyles(allStyles); + createStyleList(); + } + + function removeStyle() { + allStyles.splice(currentStyleIndex, 1); + setStyles(allStyles); + hideStyleEditor(); + createStyleList(); + } + + + ///////////////////// + + var modal = document.createElement('div'); + modal.id = 'cssEditor-Modal'; + + modalContent.appendChild(modalHeader); + modalContent.appendChild(modalList); + modalContent.appendChild(modalFooter); + modal.appendChild(modalContent); + + body.appendChild(modal); + + modal.style.display = "none"; + modal.style.position = 'fixed'; + modal.style.zIndex = '1'; + modal.style.left = '0'; + modal.style.top = '0'; + modal.style.width = '100%'; + modal.style.height = '100%'; + modal.style.overflow = 'auto'; + modal.style.backgroundColor = 'rgba(210, 210, 210, 1)'; + + modalContent.style.zIndex = '2'; + modalContent.style.backgroundColor = '#fff'; + modalContent.style.margin = '5% auto'; + modalContent.style.padding = '0'; + modalContent.style.width = '70%'; + + window.onclick = function(event) { + if (event.target == modal) { + closeModal(); + } + }; + + modal.style.display = "block"; + + document.onkeydown = function(evt) { + evt = evt || window.event; + if (evt.keyCode == 27) { + closeModal(); + } + }; + + function closeModal() { + for (var i=0; i]+>/gi, '').replace(/\s+/g, ' ').substring(0, 1000) + ' ...'); + }; + } + + function prepareEbook(newChapters) { + try { + if (newChapters.length === 0) { + alert('Can\'t generate an empty eBook!'); + return; + } + buildEbookFromChapters(); + } catch (e) { + console.log('Error:', e); + } + } + + function saveChanges() { + var newChapters = []; + var newEbookTitle = ebookTilte.value; + if (newEbookTitle.trim() === '') { + newEbookTitle = 'eBook'; + } + + try { + var tmpChaptersList = document.getElementsByClassName('cssEditor-chapter-item'); + if (!tmpChaptersList || !allPagesRef) { + return; + } + + for (var i = 0; i < tmpChaptersList.length; i++) { + var listIndex = Number(tmpChaptersList[i].id.replace('li', '')); + if (allPagesRef[listIndex].removed === false) { + newChapters.push(allPagesRef[listIndex]); + } + } + + saveEbookTitle(newEbookTitle); + saveEbookPages(newChapters); + return newChapters; + } catch (e) { + console.log('Error:', e); + } + } + + ///////////////////// + + getStyles(createStyleList); +} diff --git a/web-extension/cssjson.js b/web-extension/cssjson.js new file mode 100644 index 0000000..01b6332 --- /dev/null +++ b/web-extension/cssjson.js @@ -0,0 +1,297 @@ +/** + * CSS-JSON Converter for JavaScript + * Converts CSS to JSON and back. + * Version 2.1 + * + * Released under the MIT license. + * + * Copyright (c) 2013 Aram Kocharyan, http://aramk.com/ + + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + documentation files (the "Software"), to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + to permit persons to whom the Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in all copies or substantial portions + of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + */ + +var CSSJSON = new function () { + + var base = this; + + base.init = function () { + // String functions + String.prototype.trim = function () { + return this.replace(/^\s+|\s+$/g, ''); + }; + + String.prototype.repeat = function (n) { + return new Array(1 + n).join(this); + }; + }; + base.init(); + + var selX = /([^\s\;\{\}][^\;\{\}]*)\{/g; + var endX = /\}/g; + var lineX = /([^\;\{\}]*)\;/g; + var commentX = /\/\*[\s\S]*?\*\//g; + var lineAttrX = /([^\:]+):([^\;]*);/; + + // This is used, a concatenation of all above. We use alternation to + // capture. + var altX = /(\/\*[\s\S]*?\*\/)|([^\s\;\{\}][^\;\{\}]*(?=\{))|(\})|([^\;\{\}]+\;(?!\s*\*\/))/gmi; + + // Capture groups + var capComment = 1; + var capSelector = 2; + var capEnd = 3; + var capAttr = 4; + + var isEmpty = function (x) { + return typeof x == 'undefined' || x.length == 0 || x == null; + }; + + var isCssJson = function (node) { + return !isEmpty(node) ? (node.attributes && node.children) : false; + } + + /** + * Input is css string and current pos, returns JSON object + * + * @param cssString + * The CSS string. + * @param args + * An optional argument object. ordered: Whether order of + * comments and other nodes should be kept in the output. This + * will return an object where all the keys are numbers and the + * values are objects containing "name" and "value" keys for each + * node. comments: Whether to capture comments. split: Whether to + * split each comma separated list of selectors. + */ + base.toJSON = function (cssString, args) { + var node = { + children: {}, + attributes: {} + }; + var match = null; + var count = 0; + + if (typeof args == 'undefined') { + var args = { + ordered: false, + comments: false, + stripComments: false, + split: false + }; + } + if (args.stripComments) { + args.comments = false; + cssString = cssString.replace(commentX, ''); + } + + while ((match = altX.exec(cssString)) != null) { + if (!isEmpty(match[capComment]) && args.comments) { + // Comment + var add = match[capComment].trim(); + node[count++] = add; + } else if (!isEmpty(match[capSelector])) { + // New node, we recurse + var name = match[capSelector].trim(); + // This will return when we encounter a closing brace + var newNode = base.toJSON(cssString, args); + if (args.ordered) { + var obj = {}; + obj['name'] = name; + obj['value'] = newNode; + // Since we must use key as index to keep order and not + // name, this will differentiate between a Rule Node and an + // Attribute, since both contain a name and value pair. + obj['type'] = 'rule'; + node[count++] = obj; + } else { + if (args.split) { + var bits = name.split(','); + } else { + var bits = [name]; + } + for (i in bits) { + var sel = bits[i].trim(); + if (sel in node.children) { + for (var att in newNode.attributes) { + node.children[sel].attributes[att] = newNode.attributes[att]; + } + } else { + node.children[sel] = newNode; + } + } + } + } else if (!isEmpty(match[capEnd])) { + // Node has finished + return node; + } else if (!isEmpty(match[capAttr])) { + var line = match[capAttr].trim(); + var attr = lineAttrX.exec(line); + if (attr) { + // Attribute + var name = attr[1].trim(); + var value = attr[2].trim(); + if (args.ordered) { + var obj = {}; + obj['name'] = name; + obj['value'] = value; + obj['type'] = 'attr'; + node[count++] = obj; + } else { + if (name in node.attributes) { + var currVal = node.attributes[name]; + if (!(currVal instanceof Array)) { + node.attributes[name] = [currVal]; + } + node.attributes[name].push(value); + } else { + node.attributes[name] = value; + } + } + } else { + // Semicolon terminated line + node[count++] = line; + } + } + } + + return node; + }; + + /** + * @param node + * A JSON node. + * @param depth + * The depth of the current node; used for indentation and + * optional. + * @param breaks + * Whether to add line breaks in the output. + */ + base.toCSS = function (node, depth, breaks) { + var cssString = ''; + if (typeof depth == 'undefined') { + depth = 0; + } + if (typeof breaks == 'undefined') { + breaks = false; + } + if (node.attributes) { + for (i in node.attributes) { + var att = node.attributes[i]; + if (att instanceof Array) { + for (var j = 0; j < att.length; j++) { + cssString += strAttr(i, att[j], depth); + } + } else { + cssString += strAttr(i, att, depth); + } + } + } + if (node.children) { + var first = true; + for (i in node.children) { + if (breaks && !first) { + cssString += '\n'; + } else { + first = false; + } + cssString += strNode(i, node.children[i], depth); + } + } + return cssString; + }; + + /** + * @param data + * You can pass css string or the CSSJS.toJSON return value. + * @param id (Optional) + * To identify and easy removable of the style element + * @param replace (Optional. defaults to TRUE) + * Whether to remove or simply do nothing + * @return HTMLLinkElement + */ + base.toHEAD = function (data, id, replace) { + var head = document.getElementsByTagName('head')[0]; + var xnode = document.getElementById(id); + var _xnodeTest = (xnode !== null && xnode instanceof HTMLStyleElement); + + if (isEmpty(data) || !(head instanceof HTMLHeadElement)) return; + if (_xnodeTest) { + if (replace === true || isEmpty(replace)) { + xnode.removeAttribute('id'); + } else return; + } + if (isCssJson(data)) { + data = base.toCSS(data); + } + + var node = document.createElement('style'); + node.type = 'text/css'; + + if (!isEmpty(id)) { + node.id = id; + } else { + node.id = 'cssjson_' + timestamp(); + } + if (node.styleSheet) { + node.styleSheet.cssText = data; + } else { + node.appendChild(document.createTextNode(data)); + } + + head.appendChild(node); + + if (isValidStyleNode(node)) { + if (_xnodeTest) { + xnode.parentNode.removeChild(xnode); + } + } else { + node.parentNode.removeChild(node); + if (_xnodeTest) { + xnode.setAttribute('id', id); + node = xnode; + } else return; + } + + return node; + }; + + // Alias + + if (typeof window != 'undefined') { + window.createCSS = base.toHEAD; + } + + // Helpers + + var isValidStyleNode = function (node) { + return (node instanceof HTMLStyleElement) && node.sheet.cssRules.length > 0; + } + + var timestamp = function () { + return Date.now() || +new Date(); + }; + + var strAttr = function (name, value, depth) { + return '\t'.repeat(depth) + name + ': ' + value + ';\n'; + }; + + var strNode = function (name, value, depth) { + var cssString = '\t'.repeat(depth) + name + ' {\n'; + cssString += base.toCSS(value, depth + 1); + cssString += '\t'.repeat(depth) + '}\n'; + return cssString; + }; + +}; diff --git a/web-extension/extractHtml.js b/web-extension/extractHtml.js index 3f24ad9..6045420 100644 --- a/web-extension/extractHtml.js +++ b/web-extension/extractHtml.js @@ -12,6 +12,8 @@ var allowedTags = [ 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'msgroup', 'mlongdiv', 'mscarries', 'mscarry', 'mstack' ]; +var cssClassesToTmpIds = {}; +var tmpIdsToNewCss = {}; ////// @@ -188,9 +190,16 @@ function sanitize(rawContentString) { }); lastFragment = tattrs.length === 0 ? '' : ''; } else { - lastFragment = '<' + tag + '>'; } + // TODO ??? + tattrs = attrs.filter(function(attr) { + return attr.name === 'data-class'; + }).map(function(attr) { + return attr.value; + }); + lastFragment = '<' + tag + ' class="' + tattrs[0] + '"' + '>'; + results += lastFragment; lastFragment = ''; }, @@ -263,6 +272,74 @@ function getSelectedNodes() { ///// +function jsonToCss(jsonObj) { + var keys = Object.keys(jsonObj); + var result = ''; + for (var i = 0; i < keys.length; i++) { + var tmpJsonObj = jsonObj[keys[i]]; + var tmpKeys = Object.keys(tmpJsonObj); + result += '.' + keys[i] + ' {'; + for (var j = 0; j < tmpKeys.length; j++) { + result += tmpKeys[j] + ':' + tmpJsonObj[tmpKeys[j]] + ';'; + } + result += '} '; + } + return result; +} + +function extractCss(callback) { + $('body').find('*').each(function (i, pre) { + if (!$(pre).is(':visible')) { + $(pre).replaceWith(''); + } else { + var classNames = pre.getAttribute('class'); + var tmpName = cssClassesToTmpIds[classNames]; + var tmpNewCss = tmpIdsToNewCss[tmpName]; + if (!tmpName) { + tmpName = 'class-' + Math.floor(Math.random()*100000); + cssClassesToTmpIds[classNames] = tmpName; + tmpIdsToNewCss[tmpName] = {}; + } + if (!tmpNewCss) { + var style = window.getComputedStyle(pre); + tmpNewCss = {}; + tmpNewCss['font-size'] = style['font-size']; + tmpNewCss['font-weight'] = style['font-weight']; + tmpNewCss['color'] = style['color']; + tmpNewCss['background-color'] = style['background-color']; + tmpIdsToNewCss[tmpName] = tmpNewCss; + } + pre.setAttribute('data-class', tmpName); + } + }); + getCurrentStyle(function (currentStyle) { + var styleText = currentStyle.style; + var json = CSSJSON.toJSON(styleText); + var keys = Object.keys(json.children); + for (var i = 0; i < keys.length; i++) { + if (json.children[keys[i]].children['display'] && json.children[keys[i]].children['display'] === 'none') { + continue; + } + var cEls = document.querySelectorAll(keys[i]); + for (var j = 0; j < cEls.length; j++) { + var style = window.getComputedStyle(cEls[j]); + tmpNewCss = {}; + tmpNewCss['font-size'] = style['font-size']; + tmpNewCss['font-weight'] = style['font-weight']; + tmpNewCss['color'] = style['color']; + tmpNewCss['background-color'] = style['background-color']; + tmpName = 'class-' + Math.floor(Math.random()*100000); + tmpIdsToNewCss[tmpName] = tmpNewCss; + var oldClass = cEls[j].getAttribute('data-class'); + cEls[j].setAttribute('data-class', oldClass + ' ' + tmpName); + } + } + callback(jsonToCss(tmpIdsToNewCss)); + }); +} + +///// + function deferredAddZip(url, filename) { var deferred = $.Deferred(); JSZipUtils.getBinaryContent(url, function(err, data) { @@ -286,43 +363,47 @@ chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) { var result = {}; var pageSrc = ''; var tmpContent = ''; + // var styleFile = + extractCss(function (styleFile) { + if (request.type === 'extract-page') { + pageSrc = document.getElementsByTagName('body')[0]; + tmpContent = getContent(pageSrc); + } else if (request.type === 'extract-selection') { + pageSrc = getSelectedNodes(); + pageSrc.forEach(function (page) { + tmpContent += getContent(page); + }); + } else if (request.type === 'echo') { + sendResponse({ + echo: true + }); + return; + } - if (request.type === 'extract-page') { - pageSrc = document.getElementsByTagName('body')[0]; - tmpContent = getContent(pageSrc); - } else if (request.type === 'extract-selection') { - pageSrc = getSelectedNodes(); - pageSrc.forEach(function (page) { - tmpContent += getContent(page); + if (tmpContent.trim() === '') { + sendResponse(''); + return; + } + + allImages.forEach(function (tmpImg) { + imgsPromises.push(deferredAddZip(tmpImg.originalUrl, tmpImg.filename)); }); - } else if (request.type === 'echo') { - sendResponse({ - echo: true + + $.when.apply($, imgsPromises).done(function() { + var tmpTitle = getPageTitle(document.title); + result = { + url: getPageUrl(tmpTitle), + title: tmpTitle, + baseUrl: getCurrentUrl(), + styleFileContent: styleFile, + styleFileName: 'style'+Math.floor(Math.random()*100000)+'.css', + images: extractedImages, + content: tmpContent + }; + sendResponse(result); + }).fail(function(e) { + console.log('Error:', e); }); - return; - } - - if (tmpContent.trim() === '') { - sendResponse(''); - return; - } - - allImages.forEach(function (tmpImg) { - imgsPromises.push(deferredAddZip(tmpImg.originalUrl, tmpImg.filename)); - }); - - $.when.apply($, imgsPromises).done(function() { - var tmpTitle = getPageTitle(document.title); - result = { - url: getPageUrl(tmpTitle), - title: tmpTitle, - baseUrl: getCurrentUrl(), - images: extractedImages, - content: tmpContent - }; - sendResponse(result); - }).fail(function(e) { - console.log('Error:', e); }); return true; diff --git a/web-extension/manifest.json b/web-extension/manifest.json index 47a8a46..cd17312 100644 --- a/web-extension/manifest.json +++ b/web-extension/manifest.json @@ -10,7 +10,7 @@ }, "content_scripts": [{ "matches": [""], - "js": ["jquery.js", "jszip.js", "jszip-utils.js", "utils.js", "pure-parser.js", "extractHtml.js"] + "js": ["jquery.js", "jszip.js", "jszip-utils.js", "utils.js", "pure-parser.js", "cssjson.js", "extractHtml.js"] }], "background": { "scripts": ["background.js"] diff --git a/web-extension/menu.html b/web-extension/menu.html index 993c7ee..72b2d9a 100644 --- a/web-extension/menu.html +++ b/web-extension/menu.html @@ -74,6 +74,17 @@