Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/firefox' into thunderbird
Browse files Browse the repository at this point in the history
  • Loading branch information
ken107 committed May 29, 2021
2 parents e8b0bdb + 8b422ac commit 77f5509
Show file tree
Hide file tree
Showing 18 changed files with 131 additions and 34 deletions.
20 changes: 19 additions & 1 deletion css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ body {
font-weight: 400;
src: url(MaterialIcons-Regular.woff) format('woff');
}

.material-icons {
font-family: 'Material Icons';
font-weight: normal;
Expand All @@ -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;
}
22 changes: 22 additions & 0 deletions css/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ button.close {
text-decoration: none;
opacity: .75;
}
.dark-mode .close {
color: white;
}

h2 {
margin-top: 1rem;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
22 changes: 21 additions & 1 deletion css/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ body {
text-align: center;
}

#imgLoading {
height: 32px;
}

#buttons {
min-width: 85px;
text-align: center;
Expand Down Expand Up @@ -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 {
Expand All @@ -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;
Expand All @@ -95,6 +108,10 @@ body {
#toolbar .material-icons {
font-size: 1em;
}
.dark-mode #toolbar .btn {
background-color: #3e3e3e;
color: #ddd;
}

#footer {
text-align: center;
Expand All @@ -114,6 +131,9 @@ body {
text-align: center;
display: none;
}
.dark-mode #status {
color: #f88;
}

#attribution {
margin-top: 10px;
Expand Down
47 changes: 29 additions & 18 deletions custom-voices.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
</style>

<script src="js/jquery-3.1.1.min.js"></script>
Expand All @@ -30,13 +39,13 @@ <h3 class="mt-3">Enable Custom Voices</h3>
<div class="card-body">
<form>
<div class="form-group">
<input type="text" class="form-control" id="aws-access-key-id" placeholder="Access key ID" />
</div>
<div class="form-group">
<input type="text" class="form-control" id="aws-secret-access-key" placeholder="Secret access key" />
</div>
<div class="form-group">
<button type="button" class="btn btn-primary" id="aws-save-button">Save</button>
<div class="input-group">
<input type="text" class="form-control" id="aws-access-key-id" placeholder="Access key ID" />
<input type="text" class="form-control" id="aws-secret-access-key" placeholder="Secret access key" />
<div class="input-group-append">
<button type="button" class="btn btn-primary" id="aws-save-button">Save</button>
</div>
</div>
</div>
<div class="form-group">
<img id="aws-progress" class="status progress" src="img/loading.gif" />
Expand All @@ -54,10 +63,12 @@ <h3 class="mt-3">Enable Custom Voices</h3>
<div class="card-body">
<form>
<div class="form-group">
<input type="text" class="form-control" id="gcp-api-key" placeholder="API key" />
</div>
<div class="form-group">
<button type="button" class="btn btn-primary" id="gcp-save-button">Save</button>
<div class="input-group">
<input type="text" class="form-control" id="gcp-api-key" placeholder="API key" />
<div class="input-group-append">
<button type="button" class="btn btn-primary" id="gcp-save-button">Save</button>
</div>
</div>
</div>
<div class="form-group">
<img id="gcp-progress" class="status progress" src="img/loading.gif" />
Expand All @@ -75,13 +86,13 @@ <h3 class="mt-3">Enable Custom Voices</h3>
<div class="card-body">
<form>
<div class="form-group">
<input type="text" class="form-control" id="ibm-api-key" placeholder="API key" />
</div>
<div class="form-group">
<input type="text" class="form-control" id="ibm-url" placeholder="URL" />
</div>
<div class="form-group">
<button type="button" class="btn btn-primary" id="ibm-save-button">Save</button>
<div class="input-group">
<input type="text" class="form-control" id="ibm-api-key" placeholder="API key" />
<input type="text" class="form-control" id="ibm-url" placeholder="URL" />
<div class="input-group-append">
<button type="button" class="btn btn-primary" id="ibm-save-button">Save</button>
</div>
</div>
</div>
<div class="form-group">
<img id="ibm-progress" class="status progress" src="img/loading.gif" />
Expand Down
2 changes: 1 addition & 1 deletion docs/tos.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ <h2>6. AVAILABILITY OF PRODUCTS</h2>

<h2>7. USER MATERIAL</h2>

<p>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.</p>
<p>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.</p>

<p>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.</p>

Expand Down
Binary file modified img/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions js/content/google-doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down
9 changes: 5 additions & 4 deletions js/content/google-play-book.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions js/content/googleDocsUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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();
Expand All @@ -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;
}
}
Expand Down
6 changes: 6 additions & 0 deletions js/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion js/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ function execCommand(command, onEnd) {
}

if (brapi.commands)
brapi.commands.onCommand.addListener(execCommand);
brapi.commands.onCommand.addListener(function(command) {
execCommand(command)
})


/**
Expand Down
1 change: 1 addition & 0 deletions js/google-translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
})
}
Expand Down
1 change: 1 addition & 0 deletions js/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<pos.texts.length; i++) {
Expand Down
1 change: 1 addition & 0 deletions js/speech.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ function Speech(texts, options) {
return {
index: index,
texts: texts,
isRTL: /^(ar|az|dv|he|iw|ku|fa|ur)\b/.test(options.lang),
}
}

Expand Down
11 changes: 9 additions & 2 deletions languages.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Select Languages</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/common.css">
<style>
h2 {
margin-top: 15px;
Expand All @@ -15,8 +16,8 @@
}
.voice-list {
display: inline-block;
margin: 0 0 0 2em;
padding: 1em;
margin: .2em 0 .8em 1em;
padding: .5em 1em;
background-color: #f6f6f6;
color: #454545;
border: 1px solid #c5c5c5;
Expand All @@ -26,6 +27,12 @@
.voice-list input[type=radio] {
margin-right: .4em;
}
.dark-mode .voice-list {
background-color: #333;
border: none;
box-shadow: 1px 1px black;
color: #ddd;
}
</style>

<script src="js/jquery-3.1.1.min.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Loading

0 comments on commit 77f5509

Please sign in to comment.