Skip to content

Commit

Permalink
#216 #145 v3.3
Browse files Browse the repository at this point in the history
Fixed bug and improvements
  • Loading branch information
rizwansoaib authored Nov 10, 2024
1 parent b1d60ad commit c4b8079
Show file tree
Hide file tree
Showing 12 changed files with 188 additions and 182 deletions.
72 changes: 38 additions & 34 deletions Chrome-Extension/WhatsApp Monitor/background.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,44 @@
// background.js
// background.js
chrome.runtime.onInstalled.addListener(() => {

chrome.runtime.onInstalled.addListener(() => {
console.log("Extension installed and background script running.");
const manifest = chrome.runtime.getManifest();
const serverUrl = manifest.SERVER_URL; // Access your custom field
console.log('Server URL:', serverUrl); // Outputs: https://example.com/api
chrome.tabs.create({ url: 'https://github.com/rizwansoaib/whatsapp-monitor/tree/master' });

// Store the value using chrome.storage API if needed
chrome.storage.local.set({ serverUrl });
chrome.notifications.create('notificationId', {
type: 'basic',
iconUrl: 'images/icons/128.png',
title: 'TrackWapp Notification',
message: 'Notification are Enabled and Working',
priority: 2
});
});

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === "open_popup") {
chrome.action.setPopup({popup: "popup.html"}, () => {
chrome.action.openPopup();
});
}
});
/*
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if (changeInfo.status === 'complete' && tab.url.includes("*://web.whatsapp.com/*")) {
chrome.scripting.executeScript(
{
target: {tabId: tab.id},
files: ['websocket.js'],
// function: () => {}, // files or function, both do not work.
});
}
});

// Load the server URL if present
chrome.storage.local.get(['serverUrl'], (result) => {
if (result.serverUrl) {
document.getElementById('serverUrl').value = result.serverUrl;
}
});
chrome.power.requestKeepAwake('system');
chrome.power.requestKeepAwake('display');


chrome.runtime.setUninstallURL('https://htmlpreview.github.io/?https://github.com/rizwansoaib/whatsapp-monitor/blob/master/Chrome-Extension/uninstall.html');

chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
if (message.action === "open_popup") {
chrome.action.setPopup({popup: "popup.html"}, () => {
chrome.action.openPopup();
});
} else if (message.action === 'showNotification') {


chrome.notifications.create('notificationId', {
type: 'basic',
iconUrl: 'images/icons/128.png',
title: 'TrackWapp Notification',
message: `📱${message.user} is Online in WhatsApp`,
priority: 2
});

// Automatically delete the notification after 30 seconds
setTimeout(() => {
chrome.notifications.clear('notificationId');
}, 10000);

*/
}
});
Binary file modified Chrome-Extension/WhatsApp Monitor/images/icons/csv_download.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 10 additions & 5 deletions Chrome-Extension/WhatsApp Monitor/inject_wp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

function notify(user) {
/*
if (!("Notification" in window)) {
alert("This browser does not support desktop notification");
}
Expand All @@ -21,10 +22,14 @@ function notify(user) {
} else {
alert('Permission is ${Notification.permission}');
}
*/
}




function ms2HMS( ms ) {

Expand Down Expand Up @@ -317,7 +322,7 @@ function notify(user) {
}

updatebtn(startDate);

notify(name)
try{
document.querySelectorAll('#contactbtn')[0].innerHTML=name;
Expand Down
2 changes: 1 addition & 1 deletion Chrome-Extension/WhatsApp Monitor/js/server.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$(document).ready(function() {
$.ajax({
url: 'https://wpmonitor.online/status',
url: 'https://trackwapp.online/status',
method: 'GET',
success: function(response, textStatus, xhr) {
if (xhr.status === 200 && response.status === 'Server is working') {
Expand Down
2 changes: 1 addition & 1 deletion Chrome-Extension/WhatsApp Monitor/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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://wpmonitor.online/save/'+user+'/'+curd+'/'+t1+'/'+t2+'/'+t
const surl='https://trackwapp.online/save/'+user+'/'+curd+'/'+t1+'/'+t2+'/'+t
var xhr = new XMLHttpRequest();
xhr.open("GET",surl);
xhr.send()
Expand Down
8 changes: 5 additions & 3 deletions Chrome-Extension/WhatsApp Monitor/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "TrackWapp Online Monitor for WhatsApp",
"description": "Online Monitor WhatsApp Web",
"description": "Free Online Monitor WhatsApp Web",
"version": "3.3",
"author": "Rizwan Ahmad",

Expand Down Expand Up @@ -34,7 +34,9 @@
"permissions": [
"scripting",
"storage",
"activeTab"
"activeTab",
"power",
"notifications"
],

"background": {
Expand All @@ -43,7 +45,7 @@


"host_permissions": [
"*://web.whatsapp.com/*","https://notify.run/*","https://wpmonitor.online/*"
"*://web.whatsapp.com/*","https://notify.run/*","https://trackwapp.online/*"
]

}
126 changes: 93 additions & 33 deletions Chrome-Extension/WhatsApp Monitor/online.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var nno=""
var nkey;

chrome.storage.local.get('nno', function (myresult) {
nno = myresult.nno;
console.log("nno val in online.js",nno);
Expand Down Expand Up @@ -54,6 +55,17 @@ chrome.storage.local.get('pso', function (result3) {


function onotif(user) {











if(nkey==null||nkey==undefined||nkey==""||nkey=="undefined")
return
else{
Expand All @@ -74,7 +86,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://wpmonitor.online/save/'+user+'/'+curd+'/'+t1+'/'+t2+'/'+t
const surl='https://trackwapp.online/save/'+user+'/'+curd+'/'+t1+'/'+t2+'/'+t
var xhr = new XMLHttpRequest();
xhr.open("GET",surl);
xhr.send()
Expand Down Expand Up @@ -126,7 +138,30 @@ try{

user=document.querySelectorAll('#contactbtn')[0].innerHTML;
if(user!='null')
onotif(user);
{


try {

if(nno=='2')
chrome.runtime.sendMessage({action: 'showNotification', user: user});

let ttsMessage = 'TrackWapp Alert: '+user+' is Online in WhatsApp';
let utterance = new SpeechSynthesisUtterance(ttsMessage);
utterance.rate = 0.75;
utterance.pitch = 0.90;
if(pso=='1' || pso=='3')
window.speechSynthesis.speak(utterance);


onotif(user);
} catch (err) {
console.error('Error sending notification:', err);
}



}
}
catch(err){}

Expand Down Expand Up @@ -228,7 +263,24 @@ function isElementPresentById(id) {

function exec_after_delay(){

const element_present =document.querySelector('div[aria-label="Status"]').parentElement.parentElement;
let element_present=null;

try{

element_present =document.querySelector('div[aria-label="Status"]').parentElement.parentElement;

}
catch (e) {
console.log('error',e);
}


if(!element_present)
{
element_present =document.querySelector('div[title="Chats"]')

}

if(element_present && !(isElementPresentById('download')))
{

Expand Down Expand Up @@ -285,6 +337,44 @@ function exec_after_delay(){
setTimeout(exec_after_delay,20000);


async function run_script_delay(){




chrome.tabs.query({active: true, currentWindow: true}).then(([tab]) => {
chrome.scripting.executeScript(
{
target: {tabId: tab.id},
files: ['websocket.js'],
// function: () => {}, // files or function, both do not work.
})
})


chrome.tabs.query({active: true, currentWindow: true}).then(([tab]) => {
chrome.scripting.executeScript(
{
target: {tabId: tab.id},
files: ['protobuf.js'],
// function: () => {}, // files or function, both do not work.
})
})




chrome.tabs.query({active: true, currentWindow: true}).then(([tab]) => {
chrome.scripting.executeScript(
{
target: {tabId: tab.id},
files: ['main.js'],
// function: () => {}, // files or function, both do not work.
})
})
}

//setTimeout(run_script_delay,20000);



Expand Down Expand Up @@ -334,40 +424,10 @@ chrome.storage.sync.get('numarray', function (data) {



/*
chrome.tabs.query({active: true, currentWindow: true}).then(([tab]) => {
chrome.scripting.executeScript(
{
target: {tabId: tab.id},
files: ['websocket.js'],
// function: () => {}, // files or function, both do not work.
})
})
chrome.tabs.query({active: true, currentWindow: true}).then(([tab]) => {
chrome.scripting.executeScript(
{
target: {tabId: tab.id},
files: ['protobuf.js'],
// function: () => {}, // files or function, both do not work.
})
})


chrome.tabs.query({active: true, currentWindow: true}).then(([tab]) => {
chrome.scripting.executeScript(
{
target: {tabId: tab.id},
files: ['main.js'],
// function: () => {}, // files or function, both do not work.
})
})


*/



Expand Down
Loading

0 comments on commit c4b8079

Please sign in to comment.