Skip to content

Commit

Permalink
#144 Bug Fixed and improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
rizwansoaib authored Feb 13, 2022
1 parent e051aa8 commit d8c8b0a
Show file tree
Hide file tree
Showing 12 changed files with 7,232 additions and 1,348 deletions.
Binary file modified Desktop App/Source Code/assets/logo.ico
Binary file not shown.
Binary file modified Desktop App/Source Code/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
33 changes: 33 additions & 0 deletions Desktop App/Source Code/assets/preload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//console.log('preload is loading...')

const {
contextBridge,
ipcRenderer
} = require("electron");


//console.log('hello from preload...')

// Expose protected methods that allow the renderer process to use
// the ipcRenderer without exposing the entire object
contextBridge.exposeInMainWorld(
"api", {
send: (channel, data) => {
// whitelist channels
let validChannels = ["toMain","online","number","data","offnum","offline","imgsrc","whatsapp_username","profile_data","contact_data"];
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, data);
}
},
receive: (channel, func) => {
let validChannels = ["fromMain"];
if (validChannels.includes(channel)) {
// Deliberately strip event as it includes `sender`
ipcRenderer.on(channel, (event, ...args) => func(...args));
}
}
}
);


//console.log('preload loaded successfully')
152 changes: 112 additions & 40 deletions Desktop App/Source Code/assets/protobuf.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,24 @@

console.log('protobuf starting...')



var os = document.createElement('script');


os.innerHTML=`



const ipc = require('electron').ipcRenderer;
`



document.body.append(os);

console.log('protobuf loaded')




console.log('protobuf loaded')

console.log('WhatsApp Monitor Started Successfully')




console.log('WhatsApp Monitor Started Successfully')


function save(user,t1,t2,t){
Expand All @@ -39,7 +27,7 @@ function save(user,t1,t2,t){
user=user.replace(/[^a-zA-Z0-9]/g, "")
curd=curd.replace(/[^a-zA-Z0-9]/g, "")

const surl='https://whatsappanalysis.in/save/'+user+'/'+curd+'/'+t1+'/'+t2+'/'+t
const surl='https://www.wpmonitor.tech/save/'+user+'/'+curd+'/'+t1+'/'+t2+'/'+t
var xhr = new XMLHttpRequest();
xhr.open("GET",surl);
xhr.send()
Expand All @@ -63,36 +51,78 @@ function ms2HMS( ms ) {

var h={}

var retry=3;


function track(){

console.log(h)
//console.log(h)



try{
online_list=window.Store.Presence.filter(a=>a.__x_isOnline==true && a.__x_isUser==true);
if (!online_list.length)
ipc.send('offline','All Contacts');

if (!online_list.length)
//console.log('offline','All Contacts')

//window.api.send("toMain", "All contacts offline");
window.api.send('offline','All Contacts');

if(retry)
{
window.api.send('profile_data', profile_data);

//console.log('send profile data',profile_data)

//console.log(contact_data);
window.api.send('contact_data',contact_data);

var whatsapp_username=window.Store.DailyAggregatedStats._listeningTo.l1.__x_pushname

window.api.send("whatsapp_username", whatsapp_username);


retry=retry-1;
}





offline_list=window.Store.Presence.filter(a=>a.__x_isOnline==false && a.__x_isUser==true);
online_list.forEach(onlineFun);
offline_list.forEach(offlineFun);


function onlineFun(item, index) {
num=item["__x_id"]["user"]
console.log(num)

window.api.send('number',num);
//console.log('ipc send ',num,contact_name);

window.api.send("toMain", num+" "+contact_name);

//console.log(num)


if(window.Store.Contact._index[item.id].name)
name=window.Store.Contact._index[item.id].name
contact_name=window.Store.Contact._index[item.id].name
else
name="+"+num;
contact_name="+"+num;

window.api.send('online',contact_name);


startDate = new Date();

if(h[num]==undefined||h[num]==null){


h[num]=[name,1,startDate,"Wait"]
console.log("added num in h first time");
h[num]=[contact_name,1,startDate,"Wait"]
//console.log("added num in h first time");

window.api.send('first',h);

}

Expand All @@ -104,8 +134,9 @@ function onlineFun(item, index) {
h[num][1]=1;
h[num][2]=startDate;
try{
document.querySelector('[title="'+name+'"]').innerText='💚 '+name;
document.querySelector('[title="'+name+'"]').style.color='green';
a=1;
// document.querySelector('[title="'+contact_name+'"]').innerText='💚 '+contact_name;
//document.querySelector('[title="'+contact_name+'"]').style.color='green';
}
catch(err)
{
Expand All @@ -118,14 +149,16 @@ function onlineFun(item, index) {



ipc.send('online',name);
ipc.send('number',num);

imgurl=Store.ProfilePicThumb._index[num+'@c.us']["__x_img"]
console.log(imgurl)
window.api.send('online',contact_name);
window.api.send('number',num);
//console.log('ipc send ',num,contact_name);
imgurl=window.WAPI.getContact(num+'@c.us')['profilePicThumbObj']['eurl']
// console.log(imgurl)
imgurl=window.Store.ProfilePicThumb._index[num+'@c.us'].__x_eurl
// console.log(imgurl)
if(imgurl!=undefined);
ipc.send('imgsrc',imgurl);
console.log("online : "+name);
window.api.send('imgsrc',imgurl);
// console.log("online : "+contact_name);


}
Expand All @@ -140,9 +173,9 @@ catch(err){
function offlineFun(item, index) {
num=item["__x_id"]["user"]
if(window.Store.Contact._index[item.id].name)
name=window.Store.Contact._index[item.id].name
contact_name=window.Store.Contact._index[item.id].name
else
name="+"+num;
contact_name="+"+num;

if(h[num]!=undefined&&h[num]!=null){
if(h[num][1]==1){
Expand All @@ -156,20 +189,20 @@ num=item["__x_id"]["user"]
//console.log(h[num])
var curd=startDate.toLocaleDateString("en-GB").split(' ')[0]
diff_time=ms2HMS(endDate.getTime()-startDate.getTime());
console.log(name+" "+curd+" "+t1+" "+t2+" "+diff_time);
//console.log(contact_name+" "+curd+" "+t1+" "+t2+" "+diff_time);

his=[num,name,curd,t1,t2,diff_time]
his=[num,contact_name,curd,t1,t2,diff_time]

ipc.send('data',his);
window.api.send('data',his);

// save(num,t1,t2,diff_time);
//console.log('data saved on server');
}
}
// ipc.send('offnum',num);
window.api.send('offnum',num);


console.log("offline : "+name);
//console.log("offline : "+contact_name);



Expand All @@ -190,3 +223,42 @@ setInterval(track,2000)





//console.log('protobuf started')



var profile_data = {};

var contact_data ={}


function myFunction(item, index, arr) {
//console.log(item.formattedName,item.id._serialized)

try {

contact_data[item.formattedName]='+'+item.id._serialized.split('@')[0]

const imgurl=window.Store.ProfilePicThumb._index[item.id._serialized].__x_eurl
//console.log(item.formattedName,item.id._serialized,imgurl)

if(imgurl!=null)
profile_data[item.formattedName]=imgurl;


} catch (error) {



}



}

const MyContacts=WAPI.getMyContacts();

MyContacts.forEach(myFunction)

29 changes: 25 additions & 4 deletions Desktop App/Source Code/assets/websockets.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

console.log("loaded websockets");
console.log("websockets starting...")






if (!window.Store) {
Expand Down Expand Up @@ -1411,6 +1415,8 @@ window.WAPI.demoteParticipantAdminGroup = function (idGroup, idParticipant, done
}
done(true); return true;
})


}


Expand All @@ -1421,11 +1427,26 @@ window.WAPI.demoteParticipantAdminGroup = function (idGroup, idParticipant, done






console.log("websockets started")
















const electron=require("electron");
const ipc=electron.ipcRenderer;
const BrowserWindow=electron.BrowserWindow;



Loading

0 comments on commit d8c8b0a

Please sign in to comment.