Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions TelegramA11yFixes.user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// ==UserScript==
// @name Telegram Accessibility Fixes
// @namespace http://axSGrease.nvaccess.org/
// @description Improves the accessibility of Telegram.
// @author Michael Curran <mick@nvaccess.org>
// @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();
9 changes: 9 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,12 @@ 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/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.