-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit bc6878d
Showing
2 changed files
with
109 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
|
||
chrome.alarms.create('activityAlarm', { | ||
periodInMinutes: 10 | ||
}); | ||
|
||
chrome.alarms.onAlarm.addListener((alarm) => { | ||
if (alarm.name === 'activityAlarm') { | ||
keepVTOPSessionAlive(); | ||
} | ||
}); | ||
|
||
function keepVTOPSessionAlive() { | ||
chrome.tabs.query({ url: 'https://vtop.vit.ac.in/vtop/content' }, (tabs) => { | ||
if (tabs.length > 0) { | ||
let tabId = tabs[0].id; | ||
chrome.scripting.executeScript({ | ||
target: { tabId: tabId }, | ||
func: extractTokensAndSendRequest | ||
}, (results) => { | ||
if (chrome.runtime.lastError) { | ||
console.error('Failed to execute script:', chrome.runtime.lastError.message); | ||
} else { | ||
console.log('Request sent successfully:', results); | ||
} | ||
}); | ||
} else { | ||
chrome.tabs.create({ url: 'https://vtop.vit.ac.in/vtop/content', active: false }, (tab) => { | ||
chrome.scripting.executeScript({ | ||
target: { tabId: tab.id }, | ||
func: extractTokensAndSendRequest | ||
}, (results) => { | ||
if (chrome.runtime.lastError) { | ||
console.error('Failed to execute script:', chrome.runtime.lastError.message); | ||
} else { | ||
console.log('Request sent successfully:', results); | ||
chrome.tabs.remove(tab.id); | ||
} | ||
}); | ||
}); | ||
} | ||
}); | ||
} | ||
|
||
function extractTokensAndSendRequest() { | ||
const csrfInput = document.querySelector('input[name="_csrf"]'); | ||
const authIDInput = document.querySelector('input[name="authorizedID"]'); | ||
|
||
if (!csrfInput || !authIDInput) { | ||
console.error('CSRF token or authorizedID not found on the page.'); | ||
return; | ||
} | ||
|
||
const csrfToken = csrfInput.value; | ||
const authorizedID = authIDInput.value; | ||
|
||
const payload = new URLSearchParams(); | ||
payload.append('_csrf', csrfToken); | ||
payload.append('authorizedID', authorizedID); | ||
payload.append('x', new Date().toUTCString()); | ||
|
||
fetch('https://vtop.vit.ac.in/vtop/home', { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', | ||
'Accept': '*/*', | ||
'Accept-Language': 'en-US,en;q=0.9', | ||
'Cache-Control': 'no-cache', | ||
'Origin': 'https://vtop.vit.ac.in', | ||
'Pragma': 'no-cache', | ||
'Referer': 'https://vtop.vit.ac.in/vtop/content', | ||
'Sec-Fetch-Dest': 'empty', | ||
'Sec-Fetch-Mode': 'cors', | ||
'Sec-Fetch-Site': 'same-origin', | ||
'User-Agent': navigator.userAgent, | ||
'X-Requested-With': 'XMLHttpRequest' | ||
}, | ||
body: payload.toString(), | ||
credentials: 'include' | ||
}) | ||
.then(response => { | ||
if (response.ok) { | ||
console.log('Activity request sent successfully.'); | ||
} else { | ||
console.error('Failed to send activity request:', response.statusText); | ||
} | ||
}) | ||
.catch(error => { | ||
console.error('Error sending activity request:', error); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "VTOP Activity", | ||
"version": "1.0", | ||
"description": "Sends periodic requests to VTOP to simulate user activity in the background.", | ||
"permissions": [ | ||
"alarms", | ||
"cookies", | ||
"scripting", | ||
"tabs" | ||
], | ||
"host_permissions": [ | ||
"https://vtop.vit.ac.in/*" | ||
], | ||
"background": { | ||
"service_worker": "background.js" | ||
} | ||
} | ||
|