Parcourir la source

Added an option to remove menu entry

Gildas lormeau il y a 15 ans
Parent
commit
2c815d8ae4

+ 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: 560px;
+	height: 591px;
 }
 
 #title {

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

@@ -72,6 +72,12 @@ folder</a> - <a href="#notes">Technical notes</a> - <a href="#knownIssues">Known
 		<p>Check this option to send the processed page to <a href="https://chrome.google.com/webstore/detail/ihkkeoeinpbomhnpkmmkpggkaefincbn">Scrapbook for SingleFile</a>.</p>
 		<p class="notice">It is recommended to <u>uncheck</u> this option</p>
 		</li>
+		
+		
+		<li><span class="option">display a context menu entry</span>
+		<p>Check this option to launch processing on a page with context menu.</p>
+		<p class="notice">It is recommended to <u>check</u> this option</p>
+		</li>
 
 		<li><span class="option">process in background</span>
 		<p>Check this option to process the page in background. Processing in background means it won't be blocking (only if <span class="option">display processed page</span> option

+ 14 - 12
WebContent/ui/pages/options.html

@@ -15,7 +15,7 @@
 	<div class="option">
 		<label for="removeFramesInput">remove frames <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="removeFramesInput">
 		<div class="help">
-			<p>Check this option to remove all frames on the page. It may help to reduce the file size, to remove some ads and to view saved pages on IE8.</p>
+			<p>Check this option to remove all frames on the page.</p>
 			<p class="notice">It is recommended to <u>uncheck</u> this option</p>
 		</div>
 	</div>
@@ -29,23 +29,21 @@
 	<div class="option">
 		<label for="removeScriptsInput">remove scripts <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="removeScriptsInput">
 		<div class="help">
-			<p>Check this option if you do not want to save scripts. Most of the time, you do not need scripts in the saved page. Thus they can alter it. Nevertheless if you want to save
-			page dynamic behavior then uncheck this option. If you uncheck this option then it is strongly recommended to check "process raw document" option.</p>
+			<p>Check this option if you do not want to save scripts.</p>
 			<p class="notice">It is recommended to <u>check</u> this option</p>		
 		</div>
 	</div>
 	<div class="option">
 		<label for="removeHiddenInput">remove hidden elements <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="removeHiddenInput">
 		<div class="help">
-			<p>Check this option to remove all hidden elements. This option may alter the document but can considerably reduce the saved file size.</p>
+			<p>Check this option to remove all hidden elements.</p>
 			<p class="notice">It is recommended to <u>uncheck</u> this option</p>
 		</div>
 	</div>
 	<div class="option">
 		<label for="removeUnusedCSSRulesInput">remove unused CSS rules <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="removeUnusedCSSRulesInput">
 		<div class="help">
-			<p>Check this option to remove all CSS rules that do not match any element. This option may alter the document but can considerably reduce the saved file size. If you check
-			this option, it may also introduce some incompatibilities issues in the saved page when opening it into another browser (i.e. not based on Webkit).</p>
+			<p>Check this option to remove all CSS rules that do not match any element.</p>
 			<p class="notice">It is recommended to <u>uncheck</u> this option</p>
 		</div>
 	</div>
@@ -55,13 +53,19 @@
 			<p>Check this option to send the processed page to Scrapbook for SingleFile.</p>
 			<p class="notice">It is recommended to <u>uncheck</u> this option</p>
 		</div>
+	</div>
+	<div class="option">
+		<label for="displayInContextMenuInput">display a context menu entry <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="displayInContextMenuInput">
+		<div class="help">
+			<p>Check this option to launch processing on a page with context menu.</p>
+			<p class="notice">It is recommended to <u>check</u> this option</p>
+		</div>
 	</div>	
 	<h4>Advanced options:</h4>
 	<div class="option">
 		<label for="processInBackgroundInput">process in background <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="processInBackgroundInput">
 		<div class="help">
-			<p>Check this option to process the page in background. Processing in background means it won't be blocking (only if "display processed page" option
-			is unchecked). If you uncheck this option, a shadow will prevent you to navigate into the page during the SingleFile processing but it will be faster.</p>
+			<p>Check this option to process the page in background. Processing in background means it won't be blocking.</p>
 			<p class="notice">It is recommended to <u>uncheck</u> this option</p>		
 		</div>
 	</div>
@@ -69,16 +73,14 @@
 		<div class="option">
 			<label for="savePageInput">save processed page <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="savePageInput">
 			<div class="help">
-				<p>Check this option to save the processed page on filesystem. See "Saved archives folder" in help page for more details about saving folder location. If you check
-				this option you should uncheck "display processed page" option.</p>
+				<p>Check this option to save the processed page on filesystem.</p>
 				<p class="notice">It is recommended to <u>uncheck</u> this option</p>		
 			</div>
 		</div>
 		<div class="option">
 			<label for="displayProcessedPageInput">display processed page <img class="question-mark" src="../resources/icon_question_mark.jpg"></label> <input type="checkbox" id="displayProcessedPageInput">
 			<div class="help">
-				<p>Check this option to display the processed page in the tab. This option must be checked if you want to use Chrome "Save as" dialog box to save the page. If you uncheck
-				this option then you should check "process in background" else you should uncheck "process in background".</p>
+				<p>Check this option to display the processed page in the tab.</p>
 				<p class="notice">It is recommended to <u>check</u> this option</p>
 			</div>
 		</div>

BIN
WebContent/ui/resources/options_screen.png


+ 22 - 14
WebContent/ui/scripts/bg/background.js

@@ -47,7 +47,7 @@
 	}
 
 	function process(tabId, url, processSelection) {
-		var SINGLE_FILE_CORE_EXT_ID = dev ? /*"oabofdibacblkhpogjinmdbcekfkikjc"*/ "onlinihoegnbbcmeeocfeplgbkmoidla" : "jemlklgaibiijojffihnhieihhagocma";
+		var SINGLE_FILE_CORE_EXT_ID = dev ? /* "oabofdibacblkhpogjinmdbcekfkikjc" */"onlinihoegnbbcmeeocfeplgbkmoidla" : "jemlklgaibiijojffihnhieihhagocma";
 		detectExtension(SINGLE_FILE_CORE_EXT_ID, function(detected) {
 			if (detected) {
 				if (processable(url)) {
@@ -125,18 +125,26 @@
 	chrome.browserAction.onClicked.addListener(function(tab) {
 		process(tab.id, tab.url);
 	});
-	chrome.contextMenus.create({
-		title : "Process page with SingleFile",
-		onclick : function(info, tab) {
-			process(tab.id, tab.url);
-		}
-	});
-	chrome.contextMenus.create({
-		contexts : [ "selection" ],
-		title : "Process selection with SingleFile",
-		onclick : function(info, tab) {
-			process(tab.id, tab.url, true);
-		}
-	});
+
+	singlefile.refreshMenu = function() {
+		if (singlefile.config.get().displayInContextMenu) {
+			chrome.contextMenus.create({
+				title : "Process page with SingleFile",
+				onclick : function(info, tab) {
+					process(tab.id, tab.url);
+				}
+			});
+			chrome.contextMenus.create({
+				contexts : [ "selection" ],
+				title : "Process selection with SingleFile",
+				onclick : function(info, tab) {
+					process(tab.id, tab.url, true);
+				}
+			});
+		} else
+			chrome.contextMenus.removeAll();
+	};
+	
+	singlefile.refreshMenu();
 
 })();

+ 12 - 1
WebContent/ui/scripts/bg/config.js

@@ -38,7 +38,8 @@
 			savePage : false,
 			filenameMaxLength : 90,
 			getContent : false,
-			getRawDoc : false
+			getRawDoc : false,
+			displayInContextMenu : true
 		};
 	};
 
@@ -48,5 +49,15 @@
 
 	// migration 0.1 -> 0.2
 	delete localStorage.options;
+	
+	// migration 0.2.26 -> 0.2.27
+	if (localStorage.config) {
+		var conf = singlefile.config.get();
+		if (typeof conf.displayInContextMenu == "undefined") {
+			conf.displayInContextMenu = true;
+			singlefile.config.set(conf);
+		}
+			
+	}
 
 })();

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

@@ -19,7 +19,7 @@
  */
 
 function load() {
-	var removeScriptsInput, removeFramesInput, removeObjectsInput, removeHiddenInput, removeUnusedCSSRulesInput, processInBackgroundInput, getRawDocInput, displayProcessedPageInput, savePageInput, getContentInput;
+	var removeScriptsInput, removeFramesInput, removeObjectsInput, removeHiddenInput, removeUnusedCSSRulesInput, processInBackgroundInput, getRawDocInput, displayProcessedPageInput, savePageInput, getContentInput, displayInContextMenu;
 	var bgPage = chrome.extension.getBackgroundPage(), config = bgPage.singlefile.config.get(), filenameMaxLengthInput, storageIsEnabled = (typeof window.requestFileSystem != "undefined" || typeof window.webkitRequestFileSystem != "undefined")
 			&& typeof ArrayBuffer != "undefined";
 
@@ -40,6 +40,7 @@ function load() {
 	removeObjectsInput = document.getElementById("removeObjectsInput");
 	removeHiddenInput = document.getElementById("removeHiddenInput");
 	removeUnusedCSSRulesInput = document.getElementById("removeUnusedCSSRulesInput");
+	displayInContextMenuInput = document.getElementById("displayInContextMenuInput");
 	processInBackgroundInput = document.getElementById("processInBackgroundInput");
 	getRawDocInput = document.getElementById("getRawDocInput");
 	displayProcessedPageInput = document.getElementById("displayProcessedPageInput");
@@ -54,6 +55,7 @@ function load() {
 			removeObjects : removeObjectsInput.checked,
 			removeHidden : removeHiddenInput.checked,
 			removeUnusedCSSRules : removeUnusedCSSRulesInput.checked,
+			displayInContextMenu : displayInContextMenuInput.checked,
 			processInBackground : processInBackgroundInput.checked,
 			getRawDoc : getRawDocInput.checked,
 			displayProcessedPage : displayProcessedPageInput.checked,
@@ -67,6 +69,7 @@ function load() {
 	removeObjectsInput.checked = config.removeObjects;
 	removeHiddenInput.checked = config.removeHidden;
 	removeUnusedCSSRulesInput.checked = config.removeUnusedCSSRules;
+	displayInContextMenuInput.checked = config.displayInContextMenu;
 	processInBackgroundInput.checked = config.processInBackground;
 	getRawDocInput.checked = config.getRawDoc;
 	displayProcessedPageInput.checked = config.displayProcessedPage;
@@ -74,6 +77,7 @@ function load() {
 	filenameMaxLengthInput.value = config.filenameMaxLength;
 	getContentInput.checked = config.getContent;
 	refresh();
+	displayInContextMenuInput.addEventListener("click", bgPage.singlefile.refreshMenu);
 	document.getElementById("resetButton").addEventListener("click", function() {
 		bgPage.singlefile.config.reset();
 		load();