Index: chrome/browser/resources/chromeos/select_to_speak/select_to_speak_gdocs_script.js |
diff --git a/chrome/browser/resources/chromeos/select_to_speak/select_to_speak_gdocs_script.js b/chrome/browser/resources/chromeos/select_to_speak/select_to_speak_gdocs_script.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..144c53f4feaf93e93bac0dea330e9c5512440b9a |
--- /dev/null |
+++ b/chrome/browser/resources/chromeos/select_to_speak/select_to_speak_gdocs_script.js |
@@ -0,0 +1,24 @@ |
+// Copyright 2017 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+var tries = 10; |
+ |
+// Google Docs isn't compatible with Select-to-speak by default because |
+// in order to provide screen reader support, most of the rendered |
+// document has aria-hidden set on it, which has the side effect of |
+// hiding it from Select-to-speak too. Fix it by changing aria-hidden |
+// to false. Try multiple times in case the page isn't fully loaded when |
+// the content script runs. |
+function RemoveAriaHiddenFromGoogleDocsContent() { |
+ var element = document.querySelector('.kix-zoomdocumentplugin-outer'); |
+ if (element) { |
+ element.setAttribute('aria-hidden', 'false'); |
+ } else { |
+ tries--; |
+ if (tries > 0) |
+ window.setTimeout(RemoveAriaHiddenFromGoogleDocsContent, 1000); |
+ } |
+} |
+ |
+RemoveAriaHiddenFromGoogleDocsContent(); |