Add locale support

This commit is contained in:
TotalCaesar659 2020-09-26 03:50:56 +03:00
parent 3edabbe27c
commit 49cbf77640
5 changed files with 240 additions and 31 deletions

View file

@ -0,0 +1,98 @@
{
"extensionName": {
"message": "User-Agent Switcher and Manager",
"description": "Name of the extension."
},
"extensionDescription": {
"message": "Spoof websites trying to gather information about your web navigation to deliver distinct content you may not want",
"description": "Description of the extension."
},
"testUA": {
"message": "Test UA",
"description": ""
},
"userAgentSwitcherandManagerOptions": {
"message": "User-Agent Switcher and Manager :: Options",
"description": ""
},
"blackListMode": {
"message": "Black-List Mode",
"description": ""
},
"description": {
"message": "Description",
"description": ""
},
"blackListModeDescription": {
"message": "Apply the custom user-agent string to all tabs except the tabs with the following top-level hostnames (comma-separated list of hostnames). Note that even if a window-based user-agent string is set from the toolbar popup, your browser's default user-agent string is used.",
"description": ""
},
"whiteListMode": {
"message": "White-List Mode",
"description": ""
},
"whiteListModeDescription": {
"message": "Only apply the custom user-agent string to the tabs with following top-level hostnames. Note that if a window-based user-agent string is set from the toolbar popup, this user-agent will overwrite the global one.",
"description": ""
},
"customMode": {
"message": "Custom Mode",
"description": ""
},
"cache": {
"message": "Use caching to improve performance (recommended value is true). Uncheck this option only if you are using the custom mode and also you need the user-agent string to be altered from the provided list on every single request.",
"description": ""
},
"exactMatch": {
"message": "Use exact matching (if checked, you will need to insert all sub-domains in the white-list and black-list modes to be considered. If unchecked, all the sub-domains are passing the matching condition (e.g: www.google.com passes the matching if google.com is in the list))",
"description": ""
},
"faqs": {
"message": "Open FAQs page on updates",
"description": ""
},
"log": {
"message": "Display debugging info in the browser console",
"description": ""
},
"disableSpoofing": {
"message": "Disable Spoofing",
"description": ""
},
"disableSpoofingDescription": {
"message": "A comma-separated list of keywords that the extension should not spoof the user-agent header. Use this list to protect URLs that contain these protected keywords. Each keyword need to be at least 5 char long.",
"description": ""
},
"customUserAgentParsing": {
"message": "Custom User-Agent Parsing",
"description": ""
},
"siblingHostnames": {
"message": "Sibling Hostnames",
"description": ""
},
"importSettings": {
"message": "Import Settings",
"description": ""
},
"exportSettings": {
"message": "Export Settings",
"description": ""
},
"help": {
"message": "FAQs Page (Help)",
"description": ""
},
"donate": {
"message": "Support Development",
"description": ""
},
"reset": {
"message": "Reset",
"description": ""
},
"save": {
"message": "Save",
"description": ""
}
}

View file

@ -0,0 +1,98 @@
{
"extensionName": {
"message": "User-Agent Switcher and Manager",
"description": "Name of the extension."
},
"extensionDescription": {
"message": "Подменяет User-Agent на веб-сайтах, пытающихся собрать информацию о ваших путешествиях по сети и выдать не нужное вам содержимое",
"description": "Description of the extension."
},
"testUA": {
"message": "Тест UA",
"description": ""
},
"userAgentSwitcherandManagerOptions": {
"message": "User-Agent Switcher and Manager :: Настройки",
"description": ""
},
"blackListMode": {
"message": "Режим черного списка",
"description": ""
},
"description": {
"message": "Описание",
"description": ""
},
"blackListModeDescription": {
"message": "Применить заданную строку User-Agent ко всем вкладкам за исключением содержащих следующие домены верхнего уровня (список доменов разделяется запятыми). Важно: даже если применяемая к окну строка User-Agent задана из всплывающего окна, для этого списка будет использоваться строка User-Agent вашего браузера по умолчанию.",
"description": ""
},
"whiteListMode": {
"message": "Режим белого списка",
"description": ""
},
"whiteListModeDescription": {
"message": "Применять заданную строку User-Agent только к вкладкам, содержащим следующие домены верхнего уровня. Важно: даже если применяемая к окну строка User-Agent задана из всплывающего окна, данный User-Agent заменит собой глобальный.",
"description": ""
},
"customMode": {
"message": "Режим настройки",
"description": ""
},
"cache": {
"message": "Использовать кэширование для улучшения производительности (рекомендуемое значение true). Отключите эту опцию только при использовании режима настройки, когда нужно изменять строку User-Agent с помощью списка при каждом запросе.",
"description": ""
},
"exactMatch": {
"message": "Использовать точное совпадение (если включено, вам нужно добавлять все поддомены в черный и белый списки как задумано. Если выключено, все поддомены проходят проверку на совпадение (например, www.google.com проходит проверку, если google.com находится в списке))",
"description": ""
},
"faqs": {
"message": "Открывать страницу FAQ при обновлении",
"description": ""
},
"log": {
"message": "Отображать отладочную информацию в консоли браузера",
"description": ""
},
"disableSpoofing": {
"message": "Отключить подмену User-Agent",
"description": ""
},
"disableSpoofingDescription": {
"message": "Разделяемый запятыми список ключевых слов, на которых расширение не должно подменять заголовок User-Agent. Используйте этот список для защиты URL, содержащих эти ключевые слова. Каждое ключевое слово должно быть длиной не менее 5 символов.",
"description": ""
},
"customUserAgentParsing": {
"message": "Парсинг заданного User-Agent",
"description": ""
},
"siblingHostnames": {
"message": "Родственные домены",
"description": ""
},
"importSettings": {
"message": "Импортировать настройки",
"description": ""
},
"exportSettings": {
"message": "Экспортировать настройки",
"description": ""
},
"help": {
"message": "Страница FAQ (Помощь)",
"description": ""
},
"donate": {
"message": "Поддержать разработку",
"description": ""
},
"reset": {
"message": "Сбросить",
"description": ""
},
"save": {
"message": "Сохранить",
"description": ""
}
}

View file

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>User-Agent Switcher and Manager :: Options</title> <title data-localize="__MSG_userAgentSwitcherandManagerOptions__">User-Agent Switcher and Manager :: Options</title>
<link rel="stylesheet" type="text/css" href="index.css"> <link rel="stylesheet" type="text/css" href="index.css">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
</head> </head>
@ -9,70 +9,70 @@
<body> <body>
<div class="mode"> <div class="mode">
<input type="radio" name="mode" value="blacklist" id="mode-blacklist"> <input type="radio" name="mode" value="blacklist" id="mode-blacklist">
<label for="mode-blacklist"><h1>Black-List Mode</h1></label> <label for="mode-blacklist"><h1 data-localize="__MSG_blackListMode__">Black-List Mode</h1></label>
<span id="toggle-blacklist-desc">Description</span> <span id="toggle-blacklist-desc" data-localize="__MSG_description__">Description</span>
</div> </div>
<p for="toggle-blacklist-desc" class="note hidden">Apply the custom user-agent string to all tabs except the tabs with the following top-level hostnames (comma-separated list of hostnames). Note that even if a window-based user-agent string is set from the toolbar popup, your browser's default user-agent string is used.</p> <p for="toggle-blacklist-desc" class="note hidden" data-localize="__MSG_blackListModeDescription__">Apply the custom user-agent string to all tabs except the tabs with the following top-level hostnames (comma-separated list of hostnames). Note that even if a window-based user-agent string is set from the toolbar popup, your browser's default user-agent string is used.</p>
<textarea id="blacklist" rows="3" placeholder="e.g.: www.google.com, www.bing.com"></textarea> <textarea id="blacklist" rows="3" placeholder="e.g.: www.google.com, www.bing.com"></textarea>
<div class="mode"> <div class="mode">
<input type="radio" name="mode" value="whitelist" id="mode-whitelist"> <input type="radio" name="mode" value="whitelist" id="mode-whitelist">
<label for="mode-whitelist"><h1>White-List Mode</h1></label> <label for="mode-whitelist"><h1 data-localize="__MSG_whiteListMode__">White-List Mode</h1></label>
<span id="toggle-whitelist-desc">Description</span> <span id="toggle-whitelist-desc" data-localize="__MSG_description__">Description</span>
</div> </div>
<p for="toggle-whitelist-desc" class="note hidden">Only apply the custom user-agent string to the tabs with following top-level hostnames. Note that if a window-based user-agent string is set from the toolbar popup, this user-agent will overwrite the global one.</p> <p for="toggle-whitelist-desc" class="note hidden" data-localize="__MSG_whiteListModeDescription__">Only apply the custom user-agent string to the tabs with following top-level hostnames. Note that if a window-based user-agent string is set from the toolbar popup, this user-agent will overwrite the global one.</p>
<textarea id="whitelist" rows="3" placeholder="e.g.: www.google.com, www.bing.com"></textarea> <textarea id="whitelist" rows="3" placeholder="e.g.: www.google.com, www.bing.com"></textarea>
<div class="mode"> <div class="mode">
<input type="radio" name="mode" value="custom" id="mode-custom"> <input type="radio" name="mode" value="custom" id="mode-custom">
<label for="mode-custom"><h1>Custom Mode</h1></label> <label for="mode-custom"><h1 data-localize="__MSG_customMode__">Custom Mode</h1></label>
<span id="toggle-custom-desc">Description</span> <span id="toggle-custom-desc" data-localize="__MSG_description__">Description</span>
</div> </div>
<p for="toggle-custom-desc" class="note hidden">Try to resolve the user-agent string from a JSON object; otherwise either use the default user-agent string or use the one that the user is set from the popup interface. Use "*" as the hostname to match all domains. You can randomly select from multiple user-agent strings by providing an array instead of a fixed string. If there is a "_" key in your JSON object which refers to an array of hostnames, then the extension only randomly selects the user-agent string once for each hostname inside this list. This is useful if you don't want the random user-agent to change until this browser session is over.</label> Press <a href="#" id="sample">here</a> to insert a sample JSON object.</p> <p for="toggle-custom-desc" class="note hidden" data-localize="__MSG_customModeDescription__">Try to resolve the user-agent string from a JSON object; otherwise either use the default user-agent string or use the one that the user is set from the popup interface. Use "*" as the hostname to match all domains. You can randomly select from multiple user-agent strings by providing an array instead of a fixed string. If there is a "_" key in your JSON object which refers to an array of hostnames, then the extension only randomly selects the user-agent string once for each hostname inside this list. This is useful if you don't want the random user-agent to change until this browser session is over.</label> Press <a href="#" id="sample">here</a> to insert a sample JSON object.</p>
<textarea id="custom" rows="8" wrap="off"></textarea> <textarea id="custom" rows="8" wrap="off"></textarea>
<div class="checked"> <div class="checked">
<input type="checkbox" id="cache"> <input type="checkbox" id="cache">
<label for="cache">Use caching to improve performance (recommended value is true). Uncheck this option only if you are using the custom mode and also you need the user-agent string to be altered from the provided list on every single request.</label> <label for="cache" data-localize="__MSG_cache__">Use caching to improve performance (recommended value is true). Uncheck this option only if you are using the custom mode and also you need the user-agent string to be altered from the provided list on every single request.</label>
<input type="checkbox" id="exactMatch"> <input type="checkbox" id="exactMatch">
<label for="exactMatch">Use exact matching (if checked, you will need to insert all sub-domains in the white-list and black-list modes to be considered. If unchecked, all the sub-domains are passing the matching condition (e.g: www.google.com passes the matching if google.com is in the list))</label> <label for="exactMatch" data-localize="__MSG_exactMatch__">Use exact matching (if checked, you will need to insert all sub-domains in the white-list and black-list modes to be considered. If unchecked, all the sub-domains are passing the matching condition (e.g: www.google.com passes the matching if google.com is in the list))</label>
<input type="checkbox" id="faqs"> <input type="checkbox" id="faqs">
<label for="faqs">Open FAQs page on updates</label> <label for="faqs" data-localize="__MSG_faqs__">Open FAQs page on updates</label>
<input type="checkbox" id="log"> <input type="checkbox" id="log">
<label for="log">Display debugging info in the browser console</label> <label for="log" data-localize="__MSG_log__">Display debugging info in the browser console</label>
</div> </div>
<div class="mode-2"> <div class="mode-2">
<h1>Disable Spoofing</h1> <h1 data-localize="__MSG_disableSpoofing__">Disable Spoofing</h1>
<span id="toggle-protected-desc">Description</span> <span id="toggle-protected-desc" data-localize="__MSG_description__">Description</span>
</div> </div>
<p for="toggle-protected-desc" class="note hidden">A comma-separated list of keywords that the extension should not spoof the user-agent header. Use this list to protect URLs that contain these protected keywords. Each keyword need to be at least 5 char long.</p> <p for="toggle-protected-desc" class="note hidden" data-localize="__MSG_disableSpoofingDescription__">A comma-separated list of keywords that the extension should not spoof the user-agent header. Use this list to protect URLs that contain these protected keywords. Each keyword need to be at least 5 char long.</p>
<textarea id="protected" rows="3" wrap="off"></textarea> <textarea id="protected" rows="3" wrap="off"></textarea>
<div class="mode-2"> <div class="mode-2">
<h1>Custom User-Agent Parsing</h1> <h1 data-localize="__MSG_customUserAgentParsing__">Custom User-Agent Parsing</h1>
<span id="toggle-parser-desc">Description</span> <span id="toggle-parser-desc" data-localize="__MSG_description__">Description</span>
</div> </div>
<p for="toggle-parser-desc" class="note hidden">A JSON object to bypass the internal user-agent string parsing method. The keys are the actual user-agent strings and the value of each key is an object of the keys that need to be set for the "navigator" object. You can use the "[delete]" keyword if you want a key in the "navigator" object to get deleted. Press <a href="#" id="sample-2">here</a> to insert a sample JSON object.</p> <p for="toggle-parser-desc" class="note hidden" data-localize="__MSG_customUserAgentParsingDescription__">A JSON object to bypass the internal user-agent string parsing method. The keys are the actual user-agent strings and the value of each key is an object of the keys that need to be set for the "navigator" object. You can use the "[delete]" keyword if you want a key in the "navigator" object to get deleted. Press <a href="#" id="sample-2">here</a> to insert a sample JSON object.</p>
<textarea id="parser" rows="5" wrap="off"></textarea> <textarea id="parser" rows="5" wrap="off"></textarea>
<div class="mode-2"> <div class="mode-2">
<h1>Sibling Hostnames</h1> <h1 data-localize="__MSG_siblingHostnames__">Sibling Hostnames</h1>
<span id="toggle-sibling-desc">Description</span> <span id="toggle-sibling-desc" data-localize="__MSG_description__">Description</span>
</div> </div>
<p for="toggle-sibling-desc" class="note hidden">A JSON array that contains one or more groups of hostnames to have a single user-agent string per group. For all hostnames in one group, the user-agent string calculation only occurs once, and all the other members use the same calculated string. This is useful to make sure a group of connected websites only access to the same user-agent string. Press <a href="#" id="sample-3">here</a> to insert a sample JSON array.</p> <p for="toggle-sibling-desc" class="note hidden" data-localize="__MSG_siblingHostnamesDescription__">A JSON array that contains one or more groups of hostnames to have a single user-agent string per group. For all hostnames in one group, the user-agent string calculation only occurs once, and all the other members use the same calculated string. This is useful to make sure a group of connected websites only access to the same user-agent string. Press <a href="#" id="sample-3">here</a> to insert a sample JSON array.</p>
<textarea id="siblings" rows="5" wrap="off"></textarea> <textarea id="siblings" rows="5" wrap="off"></textarea>
<div class="admin">This extension supports managed storage. All the preferences can be pre-configured by <a href="https://add0n.com/useragent-switcher.html#faq20">the domain administrator</a></div> <div class="admin">This extension supports managed storage. All the preferences can be pre-configured by <a href="https://add0n.com/useragent-switcher.html#faq20">the domain administrator</a></div>
<div id="backup"> <div id="backup">
<button id="import">Import Settings</button> <button id="import" data-localize="__MSG_importSettings__">Import Settings</button>
<button title="to generate minified version, press Shift key while pressing this button" id="export">Export Settings</button> <button title="to generate minified version, press Shift key while pressing this button" id="export" data-localize="__MSG_exportSettings__">Export Settings</button>
</div> </div>
<div id="tools"> <div id="tools">
<button id="help">FAQs Page (Help)</button> <button id="help" data-localize="__MSG_help__">FAQs Page (Help)</button>
<button id="donate">Support Development</button> <button id="donate" data-localize="__MSG_donate__">Support Development</button>
<button id="reset">Reset</button> <button id="reset" data-localize="__MSG_reset__">Reset</button>
<button id="save">Save</button> <button id="save" data-localize="__MSG_save__">Save</button>
<span id="status"></span> <span id="status"></span>
</div> </div>

View file

@ -258,3 +258,15 @@ document.getElementById('toggle-parser-desc').addEventListener('click', () => {
document.getElementById('toggle-sibling-desc').addEventListener('click', () => { document.getElementById('toggle-sibling-desc').addEventListener('click', () => {
document.querySelector('[for="toggle-sibling-desc"]').classList.toggle('hidden'); document.querySelector('[for="toggle-sibling-desc"]').classList.toggle('hidden');
}); });
const textElements = document.querySelectorAll('[data-localize]');
textElements.forEach((e) => {
const ref = e.dataset.localize;
if (ref) {
const translated= ref.replace(/__MSG_(\w+)__/g, (match, theGroup) => chrome.i18n.getMessage(theGroup));
if (translated) {
e.innerText = translated;
}
}
});

View file

@ -1,10 +1,11 @@
{ {
"manifest_version": 2, "manifest_version": 2,
"name": "User-Agent Switcher and Manager", "name": "__MSG_extensionName__",
"short_name": "useragent-switcher", "short_name": "useragent-switcher",
"version": "0.4.3", "version": "0.4.3",
"default_locale": "en",
"description": "Spoof websites trying to gather information about your web navigation to deliver distinct content you may not want", "description": "__MSG_extensionDescription__",
"permissions": [ "permissions": [
"tabs", "tabs",