소스 검색

- add a scrapbooking attribute in the external message in order to not rewrite document (faster saving in Scrapbook)
- handles "poster" attribute of VIDEO element

Gildas lormeau 15 년 전
부모
커밋
e23e1b727a
4개의 변경된 파일11개의 추가작업 그리고 9개의 파일을 삭제
  1. 1 1
      WebContent/manifest.json
  2. 4 3
      WebContent/scripts/background.js
  3. 3 2
      WebContent/scripts/core.js
  4. 3 3
      WebContent/scripts/filters.js

+ 1 - 1
WebContent/manifest.json

@@ -4,7 +4,7 @@
 		"16": "resources/icon_16.png",
 		"48": "resources/icon_48.png",
 		"128": "resources/icon_128.png" },
-	"version": "0.1.3",
+	"version": "0.1.4",
 	"description": "SingleFile helps you to archive a complete page into a single HTML file",
 	"background_page" : "pages/background.html",
 	"options_page": "pages/options.html",

+ 4 - 3
WebContent/scripts/background.js

@@ -228,7 +228,7 @@ var singlefile = {};
 		});
 	}
 
-	function processTab(tabId) {
+	function processTab(tabId, scrapbooking) {
 		function executeScripts(scripts, callback, index) {
 			if (!index)
 				index = 0;
@@ -273,7 +273,8 @@ var singlefile = {};
 				detectScrapbook(function(sendContent) {
 					tabs[tabId].top.port.postMessage({
 						start : true,
-						sendContent : sendContent
+						sendContent : sendContent,
+						scrapbooking : scrapbooking
 					});
 				});
 			});
@@ -439,7 +440,7 @@ var singlefile = {};
 			});
 			return;
 		}
-		processTab(tabId);
+		processTab(tabId, true);
 		sendResponse({});
 	});
 

+ 3 - 2
WebContent/scripts/core.js

@@ -19,7 +19,7 @@
  */
 
 (function(holder) {
-	var targetDoc, doc, options, winID, processedFrames = 0, initPageCallback, timeoutCallback, bgPort, winPort, requests = {}, requestCount = 0, responseCount = 0, sendContent;
+	var targetDoc, doc, options, winID, processedFrames = 0, initPageCallback, timeoutCallback, bgPort, winPort, requests = {}, requestCount = 0, responseCount = 0, sendContent, scrapbooking;
 
 	function storeRequest(url, callback, base64, encodedText, characterSet) {
 		if (!requests[url]) {
@@ -65,7 +65,7 @@
 	}
 
 	function setDocument() {
-		if (options.removeScripts)
+		if (options.removeScripts && !scrapbooking)
 			targetDoc.replaceChild(doc, targetDoc.documentElement);
 	}
 
@@ -174,6 +174,7 @@
 
 	function start(msg) {
 		sendContent = msg.sendContent;
+		scrapbooking = msg.scrapbooking;
 		timeoutCallback = setTimeout(initPageCallback, 1000);
 		setWinId("0");
 	}

+ 3 - 3
WebContent/scripts/filters.js

@@ -239,12 +239,12 @@
 		},
 		image : {
 			get : function(doc, sendRequest) {
-				var IMG_SELECTOR = 'link[href][rel="shortcut icon"], link[href][rel="apple-touch-icon"], link[href][rel="icon"], img[src], input[src][type="image"]';
+				var IMG_SELECTOR = 'link[href][rel="shortcut icon"], link[href][rel="apple-touch-icon"], link[href][rel="icon"], img[src], input[src][type="image"], video[poster]';
 				Array.prototype.forEach.call(doc.querySelectorAll(IMG_SELECTOR), function(node) {
-					var url = formatURL(node.href || node.src, targetDoc.baseURI);
+					var url = formatURL(node.href || node.src || node.poster, targetDoc.baseURI);
 					if (url.indexOf("data:") != 0)
 						sendRequest(url, function(data) {
-							node.setAttribute(node.href ? "href" : "src", getDataURI(data, EMPTY_PIXEL_DATA, true));
+							node.setAttribute(node.href ? "href" : node.src ? "src" : "poster", getDataURI(data, EMPTY_PIXEL_DATA, true));
 						}, true);
 				});
 			},