diff --git a/css/common.css b/css/common.css index 89ce78ea..2c4ffff9 100644 --- a/css/common.css +++ b/css/common.css @@ -9,7 +9,6 @@ body { font-weight: 400; src: url(MaterialIcons-Regular.woff) format('woff'); } - .material-icons { font-family: 'Material Icons'; font-weight: normal; @@ -24,3 +23,22 @@ body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; } + +.dark-mode { + background-color: #252525; + color: #d0d0d0; +} +.dark-mode .text-muted { + color: #999 !important; +} +.dark-mode .surface { + background-color: #323232; +} +.dark-mode .primary { + background-color: #bb86fc; + color: black; +} +.dark-mode .secondary { + background-color: #03dac6; + color: black; +} diff --git a/css/options.css b/css/options.css index dd47039b..40452983 100644 --- a/css/options.css +++ b/css/options.css @@ -40,6 +40,9 @@ button.close { text-decoration: none; opacity: .75; } +.dark-mode .close { + color: white; +} h2 { margin-top: 1rem; @@ -136,6 +139,14 @@ input[type=checkbox], input[type=radio] { background-color: #e2e6ea; border-color: #dae0e5; } +.dark-mode .btn-light { + background-color: #3e3e3e; + border-color: transparent; + color: #ddd; +} +.dark-mode .btn-light.active { + background-color: #4e4e4e; +} .btn-info { color: white; @@ -200,6 +211,14 @@ input[type=checkbox], input[type=radio] { background-color: #d1ecf1; border-color: #bee5eb; } +.dark-mode .alert-info { + background-color: #3e3e3e; + border-color: transparent; + color: #ccc; +} +.dark-mode .alert-info a { + color: #9b9bff; +} .green-check { float: right; @@ -233,6 +252,9 @@ input[type=checkbox], input[type=radio] { cursor: pointer; text-decoration: underline; } +.dark-mode #hotkeys-link { + color: #999; +} .spinner { display: inline-block; diff --git a/css/popup.css b/css/popup.css index 929dced8..ba396e89 100644 --- a/css/popup.css +++ b/css/popup.css @@ -7,6 +7,10 @@ body { text-align: center; } +#imgLoading { + height: 32px; +} + #buttons { min-width: 85px; text-align: center; @@ -53,7 +57,15 @@ body { box-sizing: border-box; } #highlight span.active { - background: yellow; + background-color: yellow; +} +.dark-mode #highlight { + background-color: #333; + border: none; + color: #d0d0d0; +} +.dark-mode #highlight span.active { + background-color: #0c4e00; } #toolbar { @@ -77,6 +89,7 @@ body { position: relative; flex: 0 1 auto; display: flex; + align-items: center; padding: .25rem .5rem; font-size: .875rem; line-height: 1.5; @@ -95,6 +108,10 @@ body { #toolbar .material-icons { font-size: 1em; } +.dark-mode #toolbar .btn { + background-color: #3e3e3e; + color: #ddd; +} #footer { text-align: center; @@ -114,6 +131,9 @@ body { text-align: center; display: none; } +.dark-mode #status { + color: #f88; +} #attribution { margin-top: 10px; diff --git a/custom-voices.html b/custom-voices.html index 1d1835ca..9fe6a52f 100644 --- a/custom-voices.html +++ b/custom-voices.html @@ -13,6 +13,15 @@ .card-body { padding-bottom: .25rem; } + .container { + min-width: 500px; + } + .dark-mode .card { + background-color: #363636; + } + .dark-mode .card-header { + background-color: #444; + } @@ -30,13 +39,13 @@

Enable Custom Voices

- -
-
- -
-
- +
+ + +
+ +
+
@@ -54,10 +63,12 @@

Enable Custom Voices

- -
-
- +
+ +
+ +
+
@@ -75,13 +86,13 @@

Enable Custom Voices

- -
-
- -
-
- +
+ + +
+ +
+
diff --git a/docs/tos.html b/docs/tos.html index 3e22dcbe..3dadc8aa 100644 --- a/docs/tos.html +++ b/docs/tos.html @@ -156,7 +156,7 @@

6. AVAILABILITY OF PRODUCTS

7. USER MATERIAL

-

7.1 The Products may let you submit material to us: for example, you may be able to upload a photo to your profile, post books and comments in the community and comment on various matters in various parts of the Products. You may be able to upload text, video, images or sounds. In these Terms, we use the term “User Material” to refer to any publically available material of any kind that you submit to us, including text, files, images, photos, video, sounds and musical or literary works. User Material does not include the account information, Product purchase, or Product use information which you provide in registering for and using Products.

+

7.1 The Products may let you submit material to us: for example, you may be able to upload a photo to your profile, post books and comments in the community and comment on various matters in various parts of the Products. You may be able to upload text, video, images or sounds. In these Terms, we use the term “User Material” to refer to any publicly available material of any kind that you submit to us, including text, files, images, photos, video, sounds and musical or literary works. User Material does not include the account information, Product purchase, or Product use information which you provide in registering for and using Products.

7.2 This section 7 sets out the rights and obligations that each of us have in connection with User Material. If you review or submit User Material, you are agreeing to do so in accordance with these Terms. If you do not want to review or submit User Material in accordance with these Terms, then you should not do so.

diff --git a/img/loading.gif b/img/loading.gif index 717398c0..faadfe5b 100644 Binary files a/img/loading.gif and b/img/loading.gif differ diff --git a/js/content/google-doc.js b/js/content/google-doc.js index 9400b6e7..3df85723 100644 --- a/js/content/google-doc.js +++ b/js/content/google-doc.js @@ -29,8 +29,8 @@ var readAloudDoc = new function() { function getTexts() { return $(".kix-paragraphrenderer", this).get() .map(getInnerText) - .filter(isNotEmpty) .map(removeDumbChars) + .filter(isNotEmpty) } function getSelectedText() { @@ -40,7 +40,7 @@ var readAloudDoc = new function() { } function removeDumbChars(text) { - return text && text.replace(/\u200c/g, ''); + return text && text.replace(/[\n\u200c]+/g, ''); } function hack() { diff --git a/js/content/google-play-book.js b/js/content/google-play-book.js index 687cbb80..cffa32e3 100644 --- a/js/content/google-play-book.js +++ b/js/content/google-play-book.js @@ -1,7 +1,8 @@ var readAloudDoc = new function() { - var btnNext = $(".gb-pagination-controls-right").get(0); - var btnPrev = $(".gb-pagination-controls-left").get(0); + var context = $(".gb-pagination-controls-right").get(0) ? undefined : parent.document.body; + var btnNext = $(".gb-pagination-controls-right", context).get(0); + var btnPrev = $(".gb-pagination-controls-left", context).get(0); var currentIndex = 0; this.getCurrentIndex = function() { @@ -16,9 +17,9 @@ var readAloudDoc = new function() { } function getTexts() { - var dontRead = $("sup").hide(); + var dontRead = $("sup", context).hide(); var texts = []; - $(".gb-segment").children(":visible").get() + $(".gb-segment", context).children(":visible").get() .forEach(function(elem) { if ($(elem).is(".liste")) handleList(elem, texts); else handleOther(elem, texts); diff --git a/js/content/googleDocsUtil.js b/js/content/googleDocsUtil.js index a24a40e1..32f736d6 100644 --- a/js/content/googleDocsUtil.js +++ b/js/content/googleDocsUtil.js @@ -202,7 +202,7 @@ var googleDocsUtil = (function () { function getLocalCaretIndex(caretX, element, simulateElement) { //Creates a span DOM for each letter var text = cleanDocumentText(element.innerText); - var container = document.createElement('div'); + var container = document.createElement('span'); var letterSpans = []; for (var i = 0; i < text.length; i++) { var textNode = document.createElement('span'); @@ -217,6 +217,7 @@ var googleDocsUtil = (function () { simulateElement.appendChild(container); // The caret is usually at the edge of the letter, we find the edge we are closest to. + var isRTL = getComputedStyle(simulateElement).getPropertyValue("direction") == "rtl"; var index = 0; var currentMinimumDistance = -1; var containerRect = container.getBoundingClientRect(); @@ -231,12 +232,12 @@ var googleDocsUtil = (function () { var rightDistance = Math.abs(caretX - right); if (leftDistance <= currentMinimumDistance) { - index = i; + index = isRTL ? i-1 : i; currentMinimumDistance = leftDistance; } if (rightDistance <= currentMinimumDistance) { - index = i + 1; + index = isRTL ? i : i+1; currentMinimumDistance = rightDistance; } } diff --git a/js/defaults.js b/js/defaults.js index e6449900..4270e078 100644 --- a/js/defaults.js +++ b/js/defaults.js @@ -37,6 +37,12 @@ var defaults = { highlightWindowSize: 2, }; +if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) { + document.addEventListener("DOMContentLoaded", function() { + document.body.classList.add("dark-mode") + }) +} + /** * HELPERS diff --git a/js/events.js b/js/events.js index aa112710..7b71fee3 100644 --- a/js/events.js +++ b/js/events.js @@ -123,7 +123,9 @@ function execCommand(command, onEnd) { } if (brapi.commands) -brapi.commands.onCommand.addListener(execCommand); +brapi.commands.onCommand.addListener(function(command) { + execCommand(command) +}) /** diff --git a/js/google-translate.js b/js/google-translate.js index de352fb3..3c46c772 100644 --- a/js/google-translate.js +++ b/js/google-translate.js @@ -124,6 +124,7 @@ window.googleTranslateSynthesizeSpeech = function(text, lang) { return batchExecute("jQ1olc", [text, lang, null]) .then(function(payload) { + if (!payload) throw new Error("Failed to synthesize text '" + text.slice(0,25) + "…' in language " + lang) return "data:audio/mpeg;base64," + payload[0]; }) } diff --git a/js/popup.js b/js/popup.js index 344fa8da..5b8e9e2e 100644 --- a/js/popup.js +++ b/js/popup.js @@ -105,6 +105,7 @@ function updateButtons() { var pos = speechPos; var elem = $("#highlight"); if (!elem.data("texts") || elem.data("texts").length != pos.texts.length || elem.data("texts").some(function(text,i) {return text != pos.texts[i]})) { + elem.css("direction", pos.isRTL ? "rtl" : ""); elem.data({texts: pos.texts, index: -1}); elem.empty(); for (var i=0; i Select Languages + diff --git a/manifest.json b/manifest.json index 3d0dc7f6..52e3179e 100644 --- a/manifest.json +++ b/manifest.json @@ -4,7 +4,7 @@ "name": "__MSG_extension_name__", "short_name": "__MSG_extension_short_name__", "description": "__MSG_extension_description__", - "version": "1.40.0", + "version": "1.42.0", "default_locale": "en", "browser_action": { diff --git a/report.html b/report.html index 2d49bdeb..0dd2b2eb 100644 --- a/report.html +++ b/report.html @@ -5,6 +5,7 @@ Report Issues + diff --git a/shortcuts.html b/shortcuts.html index b5604d6e..76f081df 100644 --- a/shortcuts.html +++ b/shortcuts.html @@ -5,12 +5,14 @@ Shortcut Keys + +