Skip to content

Instantly share code, notes, and snippets.

@shameen
Last active April 1, 2021 14:12
Show Gist options
  • Save shameen/5112ffe8ab5602ca35586614c75a4891 to your computer and use it in GitHub Desktop.
Save shameen/5112ffe8ab5602ca35586614c75a4891 to your computer and use it in GitHub Desktop.
dev tools: monitor $0 changes + notify
//This will make a desktop notification EVERY TIME the inspected element $0 changes text.
//in Google Chrome, $0 is the current element inspected in the dev tools.
var initialElem = $0;
var initialText = initialElem.innerText;
var initialVisibility = isVisible(initialElem);
function isVisible(elem) { return !(elem.offsetWidth === 0 && elem.offsetHeight === 0) }
Notification.requestPermission();
clearInterval(x);
var x = setInterval(() => {
var newText = initialElem.innerText;
var newVisibility = isVisible(initialElem)
var hasChangedText = newText != initialText;
var hasChangedVis = newVisibility != initialVisibility;
if (hasChangedText || hasChangedVis) {
var text = "changed";
if (hasChangedText)
text += " text from '"+initialText+"' to "+newText;
if (hasChangedVis)
text += " visibility from "+initialVisibility+" to "+newVisibility
new Notification("⚠️ $0 element changed", {
body:text
});
initialText = newText;
initialVisibility = newVisibility;
}
},1000);
//This will make a desktop notification THE FIRST TIME the inspected element $0 changes text.
//in Google Chrome, $0 is the current element inspected in the dev tools.
var initialElem = $0;
var initialText = initialElem.innerText;
var initialVisibility = isVisible(initialElem);
function isVisible(elem) { return !(elem.offsetWidth === 0 && elem.offsetHeight === 0) }
Notification.requestPermission();
clearInterval(x);
var x = setInterval(() => {
var newText = initialElem.innerText;
var newVisibility = isVisible(initialElem)
var hasChangedText = newText != initialText;
var hasChangedVis = newVisibility != initialVisibility;
if (hasChangedText || hasChangedVis) {
var text = "changed";
if (hasChangedText)
text += " text from '"+initialText+"' to "+newText;
if (hasChangedVis)
text += " visibility from "+initialVisibility+" to "+newVisibility
new Notification("⚠️ $0 element changed", {
body:text,
requireInteraction: true
});
clearInterval(x);
}
},1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment