i have a chrome extension code that will give info about cpu usage of all chrome process (Fired each time the Task Manager updates its process statistics, providing the dictionary of updated Process objects, indexed by process ID.) when im on an active tab
the code
chrome.tabs.onActivated.addListener((tabs) => {
let tabId = tabs.tabId;
chrome.tabs.get(tabId, (tab) => {
console.log(tab.url);
});
chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => {
if(changeInfo.status == "complete"){
console.log(tab.url);
}
});
chrome.processes.onUpdated.addListener((x) => {
console.log(x)
});
});
the problem is i want to get only specific process where its cpu usage is above 500 and get the osProcessId for further action. i tried to do validation by using for loop but it return nothing. in other word, maybe my question is how to do validation on function that always do update everytime
specific process that have cpu load above 500
validation i tried to add to chrome.processes.onUpdated.addListener
chrome.processes.onUpdated.addListener((x) => {
for(var i=0;i<x;i++){
if(x[i].cpu >= 500){
console.log(x[i].osProcessId)
}
}
});