Browse Source

added max frame size option

Gildas lormeau 12 năm trước cách đây
mục cha
commit
bcaaeb4d86

+ 1 - 0
WebContent/core/scripts/bg/background.js

@@ -28,6 +28,7 @@
 		removeUnusedCSSRules : false,
 		displayProcessedPage : false,
 		processInBackground : true,
+		maxFrameSize : 2,
 		getContent : true,
 		getRawDoc : false
 	};

+ 4 - 2
WebContent/core/scripts/bg/bgcore.js

@@ -169,8 +169,10 @@
 					selectedDocData = this.top;
 				if (this.config.processInBackground)
 					buildPage(selectedDocData, function(docData, callback) {
-						docData.parent.docFrames[docData.index].setAttribute("src", "data:text/html;charset=utf-8,"
-								+ encodeURI(singlefile.util.getDocContent(docData.doc)));
+						var content = encodeURI(singlefile.util.getDocContent(docData.doc)), maxFrameSize = that.config.maxFrameSize;
+						if (maxFrameSize && content.length > maxFrameSize)
+							content = "";
+						docData.parent.docFrames[docData.index].setAttribute("src", "data:text/html;charset=utf-8," + content);
 						delete docData.doc;
 						callback();
 					}, function(docData, callback) {

+ 1 - 1
WebContent/ui/pages/help.css

@@ -71,7 +71,7 @@ ol>li>ul>li {
 	background-image: url(../resources/options_screen.png);
 	background-repeat: no-repeat;
 	background-position: center center;
-	height: 529px;
+	height: 560px;
 }
 
 #title {

+ 5 - 0
WebContent/ui/pages/help.html

@@ -87,6 +87,11 @@
 		<p>Check this option to process the page in background. Processing in background is usually faster but can alter the page if there are critical issues with page validity.</p>
 		<p class="notice">It is recommended to <u>uncheck</u> this option</p>
 		</li>
+		
+		<li><span class="option">max frame size</span>
+		<p>Set the maximum size of embedded frames in MB.</p>
+		<p class="notice">It is recommended to set this option to <u>2</u></p>
+		</li>
 
 		<li><span class="option">Reset to default options</span>
 		<p>Reset all the options to default state.</p>

+ 7 - 1
WebContent/ui/pages/options.css

@@ -47,7 +47,7 @@ button:active {
 	margin-bottom: 12px;
 }
 
-input[type="checkbox"],button,input[type="text"] {
+input[type="checkbox"],button,input[type="text"],input[type="number"] {
 	float: right;
 	margin: 1px 0px;
 }
@@ -56,6 +56,12 @@ input[type="checkbox"] {
 	margin-top: 4px;
 }
 
+input[type="number"] {
+	width: 40px;
+	text-align: right;
+	padding-right: 2px;
+}
+
 button {
 	padding-left: 20px;
 	padding-right: 20px;

+ 8 - 1
WebContent/ui/pages/options.html

@@ -82,7 +82,14 @@
 			<p class="notice">It is recommended to <u>uncheck</u> this option</p>
 		</div>
 	</div>
-	<div class="option">	
+	<div class="option">
+		<label for="maxFrameSizeInput">max frame size <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="number" id="maxFrameSizeInput" min="0">
+		<div class="help">
+			<p>Set the maximum size of frames in MB.</p>
+			<p class="notice">It is recommended to set this option to <u>2</u></u></p>
+		</div>
+	</div>
+	<div class="option">
 		<a href="help.html" target="SingleSileHelpPage">help</a><button id="resetButton" title="Reset all the options to default (i.e. recommended) state">Reset to default options</button>
 	</div>
 </div>

BIN
WebContent/ui/resources/options_screen.png


+ 10 - 0
WebContent/ui/scripts/bg/config.js

@@ -34,6 +34,7 @@
 			removeHidden : false,
 			removeUnusedCSSRules : false,
 			processInBackground : true,
+			maxFrameSize: 2,
 			displayProcessedPage : false,
 			getContent : true,
 			getRawDoc : false,
@@ -81,5 +82,14 @@
 			singlefile.config.set(conf);
 		}
 	}
+	
+	// migration 0.3.9 -> 0.3.10
+	if (localStorage.config) {
+		var conf = singlefile.config.get();
+		if (typeof conf.maxFrameSize == "undefined") {
+			conf.maxFrameSize = 2;
+			singlefile.config.set(conf);
+		}
+	}
 
 })();

+ 4 - 1
WebContent/ui/scripts/bg/options.js

@@ -19,7 +19,7 @@
  */
 (function() {
 
-	var removeScriptsInput, removeFramesInput, removeObjectsInput, removeHiddenInput, removeUnusedCSSRulesInput, processInBackgroundInput, getRawDocInput, sendToPageArchiverInput, displayBannerInput, displayInContextMenuInput, bgPage = chrome.extension
+	var removeScriptsInput, removeFramesInput, removeObjectsInput, removeHiddenInput, removeUnusedCSSRulesInput, processInBackgroundInput, maxFrameSizeInput, getRawDocInput, sendToPageArchiverInput, displayBannerInput, displayInContextMenuInput, bgPage = chrome.extension
 			.getBackgroundPage(), config;
 
 	function refresh() {
@@ -32,6 +32,7 @@
 		displayInContextMenuInput.checked = config.displayInContextMenu;
 		displayBannerInput.checked = config.displayBanner;
 		processInBackgroundInput.checked = config.processInBackground;
+		maxFrameSizeInput.value = config.maxFrameSize;
 		getRawDocInput.checked = config.getRawDoc;
 		sendToPageArchiverInput.checked = config.sendToPageArchiver;
 		if (displayBannerInput.checked)
@@ -49,6 +50,7 @@
 			displayBanner : displayBannerInput.checked,
 			displayProcessedPage : !displayBannerInput.checked,
 			processInBackground : processInBackgroundInput.checked,
+			maxFrameSize: maxFrameSizeInput.valueAsNumber || 0,
 			getRawDoc : getRawDocInput.checked,
 			sendToPageArchiver : sendToPageArchiverInput.checked
 		});
@@ -67,6 +69,7 @@
 	displayInContextMenuInput = document.getElementById("displayInContextMenuInput");
 	displayBannerInput = document.getElementById("displayBannerInput");
 	processInBackgroundInput = document.getElementById("processInBackgroundInput");
+	maxFrameSizeInput = document.getElementById("maxFrameSizeInput");
 	getRawDocInput = document.getElementById("getRawDocInput");
 	sendToPageArchiverInput = document.getElementById("sendToPageArchiverInput");
 	displayInContextMenuInput.addEventListener("click", bgPage.singlefile.refreshMenu);