(() => {
let { offsetWidth, offsetHeight } = document.documentElement;
let walker = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT);
while (walker.nextNode()) {
let bound = walker.currentNode.getBoundingClientRect();
let isWidthOverflow = bound.right > offsetWidth || bound.left < 0;
let isHeightOverflow = bound.bottom > offsetHeight || bound.top < 0;
let { style } = walker.currentNode;
if (isWidthOverflow && isHeightOverflow) {
style.setProperty('outline', '1px dotted red', 'important');
} else if (isWidthOverflow) {
style.setProperty('outline', '1px dotted maroon', 'important');
} else if (isHeightOverflow) {
style.setProperty('outline', '1px dotted darkviolet', 'important');
} else {
continue;
}
console.log(walker.currentNode);
}
})();
Bookmarklet