From b76cd4ff64297d47f9578a1a2f0496f7fc031e2a Mon Sep 17 00:00:00 2001 From: John Wang Date: Mon, 9 Jan 2023 17:58:36 +0100 Subject: [PATCH 1/2] Fix Messenger and What's app --- app/store/ServicesList.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/app/store/ServicesList.js b/app/store/ServicesList.js index 1aa03cbe8..c5a9cdd7d 100644 --- a/app/store/ServicesList.js +++ b/app/store/ServicesList.js @@ -28,7 +28,7 @@ Ext.define('Hamsket.store.ServicesList', { ,description: locale['services[0]'] ,url: 'https://web.whatsapp.com/' ,type: 'messaging' - ,js_unread: `let checkUnread=()=>{const elements=document.querySelectorAll("#pane-side ._23LrM");let count=0;for(const i of elements){const gp=i.parentNode.parentNode;0===gp.querySelectorAll('#pane-side *[data-icon="muted"]').length&&count++}hamsket.updateBadge(count)};setInterval(checkUnread,1e3);let unregister_queue=[];navigator.serviceWorker.getRegistrations().then(registrations=>{for(const registration of registrations)unregister_queue.push(registration.unregister());return unregister_queue}).then(queue=>{}).catch(err=>{});` + ,js_unread: `let checkUnread=()=>{const elements=document.querySelectorAll("#pane-side div span div span[aria-label]");let count=0;for(const i of elements){const gp=i.parentNode.parentNode;0===gp.querySelectorAll('#pane-side *[data-icon="muted"]').length&&count++}hamsket.updateBadge(count)};setInterval(checkUnread,1e3);let unregister_queue=[];navigator.serviceWorker.getRegistrations().then(registrations=>{for(const registration of registrations)unregister_queue.push(registration.unregister());return unregister_queue}).then(queue=>{}).catch(err=>{});` }, { id: 'slack' @@ -52,11 +52,39 @@ Ext.define('Hamsket.store.ServicesList', { ,logo: 'messenger.png' ,name: 'Messenger' ,description: locale['services[3]'] - ,url: ' https://www.facebook.com/messages/' + ,url: 'https://www.messenger.com' ,type: 'messaging' ,titleBlink: true ,note: 'To enable desktop notifications, you have to go to Options inside Messenger.' - ,js_unread: `const titleTest=new RegExp("^\\((\\d+)\\)"),checkUnread=()=>{let count=0;const isNotification=titleTest.test(document.title);isNotification?count=hamsket.parseIntOrZero(titleTest.exec(document.title)[1]):(count=document.querySelectorAll("._5fx8:not(._569x),._1ht3:not(._569x)").length,0===count&&(count=document.querySelectorAll(".pq6dq46d.is6700om.qu0x051f.esr5mh6w.e9989ue4.r7d6kgcz.s45kfl79.emlxlaya.bkmhp75w.spb7xbtv.cyypbtt7.fwizqjfa").length));const messageRequests=document.querySelector("._5nxf");messageRequests&&(count+=hamsket.parseIntOrZero(messageRequests.textContent)),hamsket.updateBadge(count)};setInterval(checkUnread,3e3);` + ,js_unread: ` +checkUnread=()=>{ + + // console.log("\\\\ \\\\\\\\ "); + console.log("these are backslashes \\ \\ \\"); + const reg = /Chats, /; + console.log("reg is: " + reg); + + const mapped = Array.from(document.querySelectorAll('a[aria-label]')) + .map((x) => x.getAttribute('aria-label')); + console.log("mapped is " + mapped) + console.log("first one is: " + mapped[0]); + console.log("calling test using regex: " + reg); + console.log("result: " + reg.test(mapped[0])); + const strings = mapped.filter((x) => reg.test(x)); + + console.log("filtered is " + strings); + + var parsed = 0; + if (strings.length > 0) { + + const value = strings[0].split(" ")[1]; + + parsed = hamsket.parseIntOrZero(value); + } + hamsket.updateBadge(parsed) +}; +setInterval(checkUnread,3e3); +` }, { id: 'skype' From 5c52ac33956ccb9e81dd26317df6518af0561e5b Mon Sep 17 00:00:00 2001 From: John Wang Date: Mon, 9 Jan 2023 18:18:27 +0100 Subject: [PATCH 2/2] Remove log statements --- app/store/ServicesList.js | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/app/store/ServicesList.js b/app/store/ServicesList.js index c5a9cdd7d..bc48ef985 100644 --- a/app/store/ServicesList.js +++ b/app/store/ServicesList.js @@ -59,17 +59,10 @@ Ext.define('Hamsket.store.ServicesList', { ,js_unread: ` checkUnread=()=>{ - // console.log("\\\\ \\\\\\\\ "); - console.log("these are backslashes \\ \\ \\"); const reg = /Chats, /; - console.log("reg is: " + reg); const mapped = Array.from(document.querySelectorAll('a[aria-label]')) .map((x) => x.getAttribute('aria-label')); - console.log("mapped is " + mapped) - console.log("first one is: " + mapped[0]); - console.log("calling test using regex: " + reg); - console.log("result: " + reg.test(mapped[0])); const strings = mapped.filter((x) => reg.test(x)); console.log("filtered is " + strings); @@ -77,9 +70,9 @@ checkUnread=()=>{ var parsed = 0; if (strings.length > 0) { - const value = strings[0].split(" ")[1]; + const value = strings[0].split(" ")[1]; - parsed = hamsket.parseIntOrZero(value); + parsed = hamsket.parseIntOrZero(value); } hamsket.updateBadge(parsed) };