I’m building an extension for personal use that monitors web traffic on a certain domain (icloud.com) and sends the data to a PHP script. I have very little (next to none) experience in developing Chrome Extensions so I opted for a devtools extension after many failed attempts. This is my code right now:
manifest.json
{
"manifest_version": 3,
"name": "BytE iCloud v2",
"description": "BytE iCloud checker v2",
"version": "1.98",
"devtools_page": "devtools.html"
}
devtools.html
<!DOCTYPE html>
<html>
<head>
<script src="devtools.js"></script>
</head>
<body>
<div id="byteicl"></div>
</body>
</html>
devtools.js (this is where the problem actually lies… probably)
chrome.devtools.network.onRequestFinished.addListener(request => {
request.getContent((body) => {
if (request.request && request.request.url) {
if (request.request.method == "POST" || request.request.method == "FETCH") {
var data = new URLSearchParams();
data.set('ig', JSON.stringify({'url': request.request.url, 'data': request.response.content.text}));
fetch("http://localhost:1609/icl.php", {
method: 'POST',
mode: 'no-cors',
cache: 'no-cache',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: data
}).then(function (response) {
console.log(response);
});
}
}
});
});
Just in case someone asks me, the icl php is here:
<?php
$aj = $_POST['ig'];
file_put_contents('icl.txt', date("Y-m-d H:i:s") . ": " . $aj . "n", FILE_APPEND);
… and icl.txt looks something like this:
2024-04-26 01:49:20: {"url":"https://p50-ckdatabasews.icloud.com/database/1/com.apple.photos.cloud/production/private/records/query?remapEnums=true&getCurrentSyncToken=true&dsid=111hidden111&clientBuildNumber=2414Hotfix74&clientMasteringNumber=2414Hotfix74&clientId=personal-hidden-velue-here"}
2024-04-26 01:49:20: {"url":"https://p50-ckdatabasews.icloud.com/database/1/com.apple.photos.cloud/production/private/records/query?remapEnums=true&getCurrentSyncToken=true&dsid=111hidden111&clientBuildNumber=2414Hotfix74&clientMasteringNumber=2414Hotfix74&clientId=personal-hidden-velue-here"}
2024-04-26 01:53:22: {"url":"https://setup.icloud.com/setup/ws/1/validate?clientBuildNumber=2414Project60&clientMasteringNumber=2414B20&clientId=personal-hidden-velue-here&dsid=111hidden111"}
2024-04-26 01:53:22: {"url":"https://p50-setup.icloud.com/setup/ws/1/storageUsageInfo?clientBuildNumber=2414Project60&clientMasteringNumber=2414B20&clientId=personal-hidden-velue-here&dsid=111hidden111"}
2024-04-26 02:07:23: {"url":"https://setup.icloud.com/setup/ws/1/validate?clientBuildNumber=2414Project60&clientMasteringNumber=2414B20&clientId=personal-hidden-velue-here&dsid=111hidden111"}
2024-04-26 02:07:23: {"url":"https://p50-setup.icloud.com/setup/ws/1/storageUsageInfo?clientBuildNumber=2414Project60&clientMasteringNumber=2414B20&clientId=personal-hidden-velue-here&dsid=111hidden111"}
I’m trying to log all requests to the server, but I’m only getting the request URLs without the needed data.
2