From 68104bf78e5096a44fb484be9734dd9c92501efa Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Tue, 17 Jan 2017 14:04:32 +1000 Subject: [PATCH 1/2] Add script for the Telegram web interface which automatically reports incoming messages. --- readme.md | 8 ++++++++ telegram.user.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 telegram.user.js diff --git a/readme.md b/readme.md index f89e12b..baf98de 100644 --- a/readme.md +++ b/readme.md @@ -71,3 +71,11 @@ It does the following: - Makes day separators in the message history and the about channel pane heading accessible as headings. - Reports incoming messages automatically (using a live region). - Hides an editable area which isn't shown visually. + +### Telegram accessibility fixes +[Download Telegram Accessibility Fixes](https://github.com/nvaccess/axSGrease/raw/master/telegram.user.js) + +This script improves the accessibility of the [Telegram instant messaging](https://web.telegram.org/) web interface. + +it so far does the following: +- marks the chat history as a live region so new messages are announced automatically diff --git a/telegram.user.js b/telegram.user.js new file mode 100644 index 0000000..330e191 --- /dev/null +++ b/telegram.user.js @@ -0,0 +1,53 @@ +// ==UserScript== +// @name Telegram Accessibility Fixes +// @namespace http://axSGrease.nvaccess.org/ +// @description Improves the accessibility of Telegram. +// @author Michael Curran +// @copyright 2016 NV Access Limited +// @license GNU General Public License version 2.0 +// @version 2016.1 +// @grant GM_log +// @include https://web.telegram.org/* +// ==/UserScript== + +function init() { + var elem; + + if (elem = document.querySelector(".im_history_messages_peer")) { + // Chat history. + elem.setAttribute("aria-live", "polite"); + } +} + +function onNodeAdded(target) { + if(target.classList.contains('im_content_message_wrap')) { + target.setAttribute("aria-live", "polite"); + } +} + +function onClassModified(target) { +} + +var observer = new MutationObserver(function(mutations) { + for (var mutation of mutations) { + try { + if (mutation.type === "childList") { + for (var node of mutation.addedNodes) { + if (node.nodeType != Node.ELEMENT_NODE) + continue; + onNodeAdded(node); + } + } else if (mutation.type === "attributes") { + if (mutation.attributeName == "class") + onClassModified(mutation.target); + } + } catch (e) { + // Catch exceptions for individual mutations so other mutations are still handled. + GM_log("Exception while handling mutation: " + e); + } + } +}); +observer.observe(document, {childList: true, attributes: true, + subtree: true, attributeFilter: ["class"]}); + +init(); From 7adfe5941936aa2a6b87712850a5a2a3931b895f Mon Sep 17 00:00:00 2001 From: Michael Curran Date: Tue, 17 Jan 2017 15:41:14 +1000 Subject: [PATCH 2/2] Address review of #9 --- telegram.user.js => TelegramA11yFixes.user.js | 0 readme.md | 7 ++++--- 2 files changed, 4 insertions(+), 3 deletions(-) rename telegram.user.js => TelegramA11yFixes.user.js (100%) diff --git a/telegram.user.js b/TelegramA11yFixes.user.js similarity index 100% rename from telegram.user.js rename to TelegramA11yFixes.user.js diff --git a/readme.md b/readme.md index baf98de..2d08251 100644 --- a/readme.md +++ b/readme.md @@ -73,9 +73,10 @@ It does the following: - Hides an editable area which isn't shown visually. ### Telegram accessibility fixes -[Download Telegram Accessibility Fixes](https://github.com/nvaccess/axSGrease/raw/master/telegram.user.js) +[Download Telegram Accessibility Fixes](https://github.com/nvaccess/axSGrease/raw/master/TelegramA11yFixes.user.js) This script improves the accessibility of the [Telegram instant messaging](https://web.telegram.org/) web interface. -it so far does the following: -- marks the chat history as a live region so new messages are announced automatically +It so far does the following: + +- Marks the chat history as a live region so new messages are announced automatically.