Переглянути джерело

add "remove specific elements" option (see #1635)

Gildas 2 місяців тому
батько
коміт
b56c9324c6

+ 4 - 0
_locales/az/messages.json

@@ -315,6 +315,10 @@
 		"message": "gizli elementləri çıxarın",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "müəyyən elementləri çıxarın",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Fayl formatı",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/de/messages.json

@@ -315,6 +315,10 @@
 		"message": "Verborgene Elemente entfernen",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "spezifische Elemente entfernen",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Dateiformat",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/en/messages.json

@@ -315,6 +315,10 @@
 		"message": "remove hidden elements",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "remove specific elements",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "File format",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/es/messages.json

@@ -315,6 +315,10 @@
 		"message": "eliminar elementos ocultos (hidden)",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "eliminar elementos específicos",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Formato de archivo",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/fr/messages.json

@@ -315,6 +315,10 @@
 		"message": "supprimer les élements cachés",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "supprimer des éléments spécifiques",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Format de fichier",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/it/messages.json

@@ -315,6 +315,10 @@
 		"message": "rimuovi elementi nascosti",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "rimuovi elementi specifici",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Formato del file",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/ja/messages.json

@@ -315,6 +315,10 @@
 		"message": "隠された要素を削除する",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "特定の要素を削除する",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "ファイル形式",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/nl_NL/messages.json

@@ -315,6 +315,10 @@
 		"message": "verwijder verborgen elementen",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "specifieke elementen verwijderen",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Bestandsformaat",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/pl/messages.json

@@ -315,6 +315,10 @@
 		"message": "usuwaj ukryte elementy",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "remove specific elements",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Format pliku",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/pt_PT/messages.json

@@ -315,6 +315,10 @@
 		"message": "remover elementos ocultos",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "remover elementos específicos",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Formato de ficheiro",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/pt_br/messages.json

@@ -315,6 +315,10 @@
 		"message": "remover elementos escondidos",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "remover elementos específicos",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Formato do arquivo",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/ru/messages.json

@@ -315,6 +315,10 @@
 		"message": "удалить скрытые элементы",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "remove specific elements",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Формат файла",
 		"description": "Options sub-title: 'File format'"

+ 5 - 1
_locales/sv/messages.json

@@ -315,6 +315,10 @@
 		"message": "ta bort dolda element",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "ta bort specifika element",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Filformat",
 		"description": "Options sub-title: 'File format'"
@@ -1115,4 +1119,4 @@
 		"message": "Ogiltig JSON",
 		"description": "Options editor error message: 'Invalid JSON'"
 	}
-}
+}

+ 4 - 0
_locales/tr/messages.json

@@ -315,6 +315,10 @@
 		"message": "gizli öğeleri kaldır",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "belirli öğeleri kaldır",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Dosya biçimi",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/uk/messages.json

@@ -315,6 +315,10 @@
 		"message": "видалити приховані елементи",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "видалити певні елементи",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "Формат файлу",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/zh_CN/messages.json

@@ -315,6 +315,10 @@
 		"message": "移除隐藏元素",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "移除特定元素",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "文件格式",
 		"description": "Options sub-title: 'File format'"

+ 4 - 0
_locales/zh_TW/messages.json

@@ -315,6 +315,10 @@
 		"message": "移除隱藏元素",
 		"description": "Options page label: 'remove hidden elements'"
 	},
+	"optionRemovedElementsSelector": {
+		"message": "移除特定元素",
+		"description": "Options page label: 'remove specific elements'"
+	},
 	"optionsFileFormatSubTitle": {
 		"message": "文件格式",
 		"description": "Options sub-title: 'File format'"

Різницю між файлами не показано, бо вона завелика
+ 0 - 0
lib/single-file-extension-background.js


Різницю між файлами не показано, бо вона завелика
+ 0 - 0
lib/single-file.js


+ 4 - 4
package-lock.json

@@ -9,7 +9,7 @@
 			"version": "1.2.4",
 			"license": "AGPL-3.0-or-later",
 			"dependencies": {
-				"single-file-core": "1.5.67"
+				"single-file-core": "1.5.68"
 			},
 			"devDependencies": {
 				"@rollup/plugin-node-resolve": "16.0.3",
@@ -1642,9 +1642,9 @@
 			}
 		},
 		"node_modules/single-file-core": {
-			"version": "1.5.67",
-			"resolved": "https://registry.npmjs.org/single-file-core/-/single-file-core-1.5.67.tgz",
-			"integrity": "sha512-yYthTcJr/uoMQAZqgb3PSzgYJjJtiqIHtHcj6U/NgytMqT9zfJBWOy/qd1DT2Bk8c9wShxvYDPrJ3EjhNQuXxQ==",
+			"version": "1.5.68",
+			"resolved": "https://registry.npmjs.org/single-file-core/-/single-file-core-1.5.68.tgz",
+			"integrity": "sha512-SjAZ6hqcj9F1HnYs1Wu179wYfktFUw7GG2Tsyyw0OUWloDuRd30n+JxW39uMXW/ISfhwP4TmReCeo5Tkki0lgg==",
 			"license": "AGPL-3.0-or-later"
 		},
 		"node_modules/smob": {

+ 1 - 1
package.json

@@ -10,7 +10,7 @@
 	},
 	"type": "module",
 	"dependencies": {
-		"single-file-core": "1.5.67"
+		"single-file-core": "1.5.68"
 	},
 	"devDependencies": {
 		"eslint": "^9.39.1",

+ 1 - 0
src/core/bg/config.js

@@ -53,6 +53,7 @@ const DEFAULT_FILENAME_REPLACEMENT_CHARACTERS = ["~", "+", "?", "%", "
 
 const DEFAULT_CONFIG = {
 	removeHiddenElements: true,
+	removedElementsSelector: "",
 	removeUnusedStyles: true,
 	removeUnusedFonts: true,
 	removeFrames: false,

+ 5 - 0
src/ui/bg/ui-options.js

@@ -60,6 +60,7 @@ browser.runtime.sendMessage({ method: "config.getConstants" }).then(data => {
 	init();
 });
 const removeHiddenElementsLabel = document.getElementById("removeHiddenElementsLabel");
+const removedElementsSelectorLabel = document.getElementById("removedElementsSelectorLabel");
 const removeUnusedStylesLabel = document.getElementById("removeUnusedStylesLabel");
 const removeUnusedFontsLabel = document.getElementById("removeUnusedFontsLabel");
 const removeFramesLabel = document.getElementById("removeFramesLabel");
@@ -228,6 +229,7 @@ const fileInput = document.getElementById("fileInput");
 const profileNamesInput = document.getElementById("profileNamesInput");
 const customShortcutInput = document.getElementById("customShortcutInput");
 const removeHiddenElementsInput = document.getElementById("removeHiddenElementsInput");
+const removedElementsSelectorInput = document.getElementById("removedElementsSelectorInput");
 const removeUnusedStylesInput = document.getElementById("removeUnusedStylesInput");
 const removeUnusedFontsInput = document.getElementById("removeUnusedFontsInput");
 const removeFramesInput = document.getElementById("removeFramesInput");
@@ -680,6 +682,7 @@ addProfileButton.title = browser.i18n.getMessage("profileAddButtonTooltip");
 deleteProfileButton.title = browser.i18n.getMessage("profileDeleteButtonTooltip");
 renameProfileButton.title = browser.i18n.getMessage("profileRenameButtonTooltip");
 removeHiddenElementsLabel.textContent = browser.i18n.getMessage("optionRemoveHiddenElements");
+removedElementsSelectorLabel.textContent = browser.i18n.getMessage("optionRemovedElementsSelector");
 removeUnusedStylesLabel.textContent = browser.i18n.getMessage("optionRemoveUnusedStyles");
 removeUnusedFontsLabel.textContent = browser.i18n.getMessage("optionRemoveUnusedFonts");
 removeFramesLabel.textContent = browser.i18n.getMessage("optionRemoveFrames");
@@ -1015,6 +1018,7 @@ async function refresh(profileName) {
 	renameProfileButton.disabled = deleteProfileButton.disabled = profileNamesInput.value == DEFAULT_PROFILE_NAME;
 	const profileOptions = profiles[selectedProfileName];
 	removeHiddenElementsInput.checked = profileOptions.removeHiddenElements;
+	removedElementsSelectorInput.value = profileOptions.removedElementsSelector;
 	removeUnusedStylesInput.checked = profileOptions.removeUnusedStyles;
 	removeUnusedFontsInput.checked = profileOptions.removeUnusedFonts;
 	removeFramesInput.checked = profileOptions.removeFrames;
@@ -1212,6 +1216,7 @@ async function update() {
 		profileName: selectedProfileName,
 		profile: {
 			removeHiddenElements: removeHiddenElementsInput.checked,
+			removedElementsSelector: removedElementsSelectorInput.value,
 			removeUnusedStyles: removeUnusedStylesInput.checked,
 			removeUnusedFonts: removeUnusedFontsInput.checked,
 			removeFrames: removeFramesInput.checked,

+ 6 - 1
src/ui/pages/help.html

@@ -276,6 +276,11 @@
 							the time needed to save a page.</p>
 						<p class="notice">It is recommended to <u>check</u> this option</p>
 					</li>
+					<li data-options-label="removedElementsSelectorLabel"> <span class="option">Option: remove specific
+							elements</span>
+						<p>Use this option to remove elements from the page by providing a list of CSS selectors
+							separated by commas.</p>
+					</li>
 					<li data-options-label="insertMetaCSPLabel"> <span class="option">Option: set content security
 							policy</span>
 						<p>Check this option to add a meta tag with a policy to block any external resources from being
@@ -992,7 +997,7 @@
 						"category_index.html")</li>
 					<li><code>{url-last-segment}</code>: the last part of the pathname (without the extension) or the
 						host if not found (e.g. "index")</li>
-					<li><code>{url-filename}</code>: the file name of the URL (e.g. "index.html")</li>	
+					<li><code>{url-filename}</code>: the file name of the URL (e.g. "index.html")</li>
 					<li><code>{url-protocol}</code>: the protocol of the URL (e.g. "https")</li>
 					<li><code>{url-host}</code>: the host name + the port of the URL (e.g. "example.com_8080")</li>
 					<li><code>{url-hostname}</code>: the host name of the URL (e.g. "example.com")</li>

+ 3 - 0
src/ui/pages/help_zh_CN.html

@@ -183,6 +183,9 @@
                         <p>选中此选项可删除所有隐藏元素。选中此选项有助于在不更改文档的情况下减小文件大小。它还可能增加CPU消耗和保存页面所需的时间。</p>
                         <p class="notice">建议<u>检查</u>此选项</p>
                     </li>
+                    <li data-options-label="removedElementsSelectorLabel"> <span class="option">选项:删除特定元素</span>
+                        <p>使用此选项通过提供以逗号分隔的CSS选择器列表从页面中删除元素。</p>
+                    </li>
                     <li data-options-label="insertMetaCSPLabel"><span class="option">选项:设置内容安全策略</span>
                         <p>选中此选项可添加具有策略的元标记,以阻止加载任何外部资源。</p>
                         <p class="notice">建议<u>检查</u>此选项</p>

+ 4 - 0
src/ui/pages/options.html

@@ -158,6 +158,10 @@
 				<label for="removeHiddenElementsInput" id="removeHiddenElementsLabel"></label>
 				<input type="checkbox" id="removeHiddenElementsInput">
 			</div>
+			<div class="option vertical">
+				<label for="removedElementsSelectorInput" id="removedElementsSelectorLabel"></label>
+				<textarea id="removedElementsSelectorInput"></textarea>
+			</div>
 			<div class="option">
 				<label for="insertMetaCSPInput" id="insertMetaCSPLabel"></label>
 				<input type="checkbox" id="insertMetaCSPInput">

Деякі файли не було показано, через те що забагато файлів було змінено