Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statsObserver #26

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ var muteAllToggle = false;
var autoJoinObserver;
var refreshCycle;
var myNick;
let currentPing;
let currentMaxPing;

// for kick/ban buttons
var dblDiv = document.createElement('div');
Expand Down Expand Up @@ -934,6 +936,44 @@ moduleObserver = new MutationObserver(function(mutations) {
timer.innerText = `Current: ${dhm(curSess)} | Total: ${dhm(totSess)}`
chrome.storage.local.set({'haxTotSess': totSess}, function () {});
}, 1000);


stats = waitForElement(".stats-view");
stats.then(function(ela){
ping = statSec.childNodes[0].childNodes[1]
maxPing = statSec.childNodes[1].childNodes[1]
fps = statSec.childNodes[2].childNodes[1]
ping.setAttribute("id", "ping")
maxPing.setAttribute("id", "maxPing")
fps.setAttribute("id", "fps")

statsObserver = new MutationObserver(function(mutations) {
mutes = [...mutations]

if(mutes.length > 0 && mutes.length < 2){
onlyMute = mutes[0];

if (onlyMute.target.id == "ping") {
currentPing = [...onlyMute.addedNodes][0].textContent;
} else if (onlyMute.target.id == "maxPing") {
currentMaxPing = [...onlyMute.addedNodes][0].textContent;
} else {/* console.log('fps change') */}
} else if(mutes.length > 1) {
muteOne = mutes[0]
muteTwo = mutes[1]
if (muteOne.target.id == "ping" && muteTwo.target.id == "maxPing") {
currentPing = [...muteOne.addedNodes][0].textContent;
currentMaxPing = [...muteTwo.addedNodes][0].textContent;
} else if (muteOne.target.id == "maxPing" && muteTwo.target.id == "ping") {
currentPing = [...muteTwo.addedNodes][0].textContent;
currentMaxPing = [...muteOne.addedNodes][0].textContent;
} else { /* console.log('fps change') */ }
}
});
statsObserver.observe(ela, {childList: true, subtree: true} );
});


break;
case tempView == "dialog":
chrome.storage.local.get({'haxMuteConfig' : true}, function (items) {
Expand Down