From 4508c9ec9e19a3153571216b922c123fd6e66bb1 Mon Sep 17 00:00:00 2001 From: TheGoddessInari Date: Thu, 30 Jul 2020 14:33:21 -0700 Subject: [PATCH] Fix User Agent overrides for Google properties. --- app/store/ServicesList.js | 5 ----- app/ux/WebView.js | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/store/ServicesList.js b/app/store/ServicesList.js index a6b31887..e3a32dc9 100644 --- a/app/store/ServicesList.js +++ b/app/store/ServicesList.js @@ -75,7 +75,6 @@ Ext.define('Hamsket.store.ServicesList', { ,type: 'messaging' ,titleBlink: true ,manual_notifications: true - ,userAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0' ,js_unread: `let checkUnread=()=>{let myframe=document.getElementById("hangout-landing-chat").lastChild,mydocument=myframe.contentDocument||myframe.contentWindow.document;hamsket.updateBadge(mydocument.body.getElementsByClassName("ee").length)};setInterval(checkUnread,3e3);` }, { @@ -113,7 +112,6 @@ Ext.define('Hamsket.store.ServicesList', { ,url: 'https://mail.google.com/mail/?labs=0' ,type: 'email' ,allow_popups: true - ,userAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0' ,js_unread: `let checkUnread=()=>{const a=document.getElementsByClassName("aim")[0].textContent.split(":");hamsket.updateBadge(parseInt(a[a.length-1].replace(/[^0-9]/g,"")))};setInterval(checkUnread,3e3);` ,note: 'To enable desktop notifications, you have to go to Settings inside Gmail. Read more...' }, @@ -810,7 +808,6 @@ Ext.define('Hamsket.store.ServicesList', { ,description: 'A free phone number for life. Stay in touch from any screen. Use your free number to text, call, and check voicemail all from one app. Plus, Google Voice works on all of your devices so you can connect and communicate how you want.' ,url: 'https://voice.google.com' ,type: 'messaging' - ,userAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0' ,js_unread: `let parseIntOrZero=e=>isNaN(parseInt(e))?0:parseInt(e),checkUnread=()=>{const e=document.querySelector(".msgCount");let n=0;e?n=parseIntOrZero(e.innerHTML.replace(/[() ]/gi,"")):["Messages","Calls","Voicemail"].forEach(function(e){const r=document.querySelector('gv-nav-tab[tooltip="+e+"] div[aria-label="Unread count"]');r&&(n+=parseIntOrZero(r.innerHTML))}),hamsket.updateBadge(n)};setInterval(checkUnread,3e3);;` }, { @@ -866,7 +863,6 @@ Ext.define('Hamsket.store.ServicesList', { ,type: 'messaging' ,titleBlink: true ,manual_notifications: true - ,userAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0' ,js_unread: `let checkUnread=()=>{hamsket.updateBadge(document.querySelectorAll(".SSPGKf.EyyDtb.Q6oXP:not(.oCHqfe) .eM5l9e.FVKzAb").length)};setInterval(checkUnread,3e3);` }, { @@ -876,7 +872,6 @@ Ext.define('Hamsket.store.ServicesList', { ,description: 'Text on your computer with Messages for web.' ,url: 'https://messages.google.com/web' ,type: 'messaging' - ,userAgent: 'Mozilla/5.0 (X11; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0' ,js_unread: `let checkUnread=()=>{hamsket.updateBadge(Array.prototype.slice.apply(document.querySelectorAll(".text-content.unread")).reduce((c,b) => !b.querySelector(".notifications-off")+c,0))};setInterval(checkUnread,3e3);` } ] diff --git a/app/ux/WebView.js b/app/ux/WebView.js index b4a7d3f9..0f3c5254 100644 --- a/app/ux/WebView.js +++ b/app/ux/WebView.js @@ -231,6 +231,21 @@ Ext.define('Hamsket.ux.WebView',{ console.info('Start loading...', me.src); if ( !me.down('statusbar').closed || !me.down('statusbar').keep ) me.down('statusbar').show(); me.down('statusbar').showBusy(); + me.getWebContents().session.webRequest.onBeforeSendHeaders( + { + urls: [ + 'https://accounts.google.com/signin/', + 'https://accounts.google.com/signin/*', + 'https://accounts.google.com/ServiceLogin?*' + ] + }, + (details, callback) => { + details.requestHeaders['User-Agent'] = + 'Mozilla/5.0 (X11; Linux x86_64; rv:79.0) Gecko/20100101 Firefox/79.0'; + callback({ requestHeaders: details.requestHeaders }); + } + ); + }); webview.addEventListener("did-stop-loading", function() { me.down('statusbar').clearStatus({useDefaults: true});