Browse Source

Fixes #183

pull/258/head
Ramiro Saenz 9 years ago
parent
commit
ed9766c7ab
  1. 3
      app/store/ServicesList.js
  2. 7
      app/ux/WebView.js

3
app/store/ServicesList.js

@ -87,8 +87,9 @@ Ext.define('Rambox.store.ServicesList', {
,logo: 'telegram.png' ,logo: 'telegram.png'
,name: 'Telegram' ,name: 'Telegram'
,description: 'Telegram is a messaging app with a focus on speed and security. It’s super-fast, simple, secure and free.' ,description: 'Telegram is a messaging app with a focus on speed and security. It’s super-fast, simple, secure and free.'
,url: 'https://web.telegram.org/#/login' ,url: 'https://web.telegram.org/'
,type: 'messaging' ,type: 'messaging'
,js_unread: 'function checkUnread(){var e=document.getElementsByClassName("im_dialog_badge badge"),t=0;for(i=0;i<e.length;i++)t+=parseInt(e[i].innerHTML.trim());updateBadge(t)}function updateBadge(e){document.title="("+e+") RamboxService"}setInterval(checkUnread,3000);'
}, },
{ {
id: 'wechat' id: 'wechat'

7
app/ux/WebView.js

@ -160,11 +160,16 @@ Ext.define('Rambox.ux.WebView',{
console.groupCollapsed('JS Injected to Detect New Messages'); console.groupCollapsed('JS Injected to Detect New Messages');
console.info(me.type); console.info(me.type);
console.log(js_unread); console.log(js_unread);
console.groupEnd()
webview.executeJavaScript(js_unread); webview.executeJavaScript(js_unread);
} }
} }
// Prevent Title blinking (some services have) and only allow when the title have an unread regex match: "(3) Title"
var js_preventBlink = 'var originalTitle=document.title;Object.defineProperty(document,"title",{configurable:!0,set:function(a){null===a.match(new RegExp("[(]([0-9]+)[)][ ](.*)","g"))&&a!==originalTitle||(document.getElementsByTagName("title")[0].innerHTML=a)},get:function(){return document.getElementsByTagName("title")[0].innerHTML}});';
console.log(js_preventBlink);
console.groupEnd()
webview.executeJavaScript(js_preventBlink);
// Scroll always to top (bug) // Scroll always to top (bug)
webview.executeJavaScript('document.body.scrollTop=0;'); webview.executeJavaScript('document.body.scrollTop=0;');
}); });

Loading…
Cancel
Save