2
// @include https://twitter.com/*
6
window.Unity = external.getUnityObject(1);
8
function isCorrectPage() {
9
var i, ids = ['doc', 'banners', 'page-outer', 'global-nav-home', 'global-new-tweet-button'];
11
for (i = 0; i < ids.length; i++) {
12
if (!document.getElementById(ids[i])) {
20
function messagingIndicatorSetup() {
21
function checkMessangesCount() {
23
var search = document.getElementsByClassName('flex-table-input search-query js-search-header-query')[0];
24
if (search) { // stream for #tag
27
if (document.getElementsByClassName('module mini-profile component')[0]) { // home screen
33
var countElement = document.getElementsByClassName('new-tweets-bar js-new-tweets-bar')[0];
35
count = countElement.textContent.match(/\d+/)[0];
37
// empty callback raise current tab
38
reportTestState(title + count);
39
Unity.MessagingIndicator.showIndicator(title, { count: count,
40
callback: function () {} });
43
setInterval(wrapCallback(checkMessangesCount), 3000);
46
if (isCorrectPage()) {
47
var prefix = 'https://twitter.com/';
49
var profileLink = document.evaluate('//a[@data-nav="profile"]', document, null, XPathResult.ANY_UNORDERED_NODE_TYPE, null).singleNodeValue;
50
var login = profileLink.href;
52
if (login.substr(0, prefix.length) === prefix) {
53
login = login.substr(prefix.length);
58
Unity.init({ name: "Twitter",
60
domain: 'twitter.com',
61
homepage: 'https://twitter.com/',
62
iconUrl: "icon://twitter",
63
onInit: wrapCallback(messagingIndicatorSetup) });