如何清除 Rails Web 控制台?
更好的错误 Web 控制台的图像链接
我开发了一些 JavaScript,可以塞进一个小书签并在浏览器中使用以清除实时控制台。
var consoleElements = document.querySelectorAll('.console');
var arrayLength = consoleElements.length;
if(arrayLength<1){
console.log("No consoles found to clear.");
} else {
for (var i = 0; i < arrayLength; i++) {
var consoleElement = consoleElements[i];
var consoleHistoryElement = consoleElement.querySelector('pre');
consoleHistoryElement.innerHTML = "";
consoleHistoryElement.style.backgroundColor = "#FF906F";
setTimeout(function() {
consoleHistoryElement.style.transition = "background-color 1.5s";
consoleHistoryElement.style.backgroundColor = "";
setTimeout(function() {
consoleHistoryElement.style.transition = "";
}, 1500);
}, 0);
}
console.log(arrayLength + " consoles cleared.");
}
javascript:var consoleElements=document.querySelectorAll('.console');var arrayLength=consoleElements.length;if(arrayLength<1){console.log("No consoles found to clear.");}else{for(var i=0;i<arrayLength;i++){var consoleElement=consoleElements[i];var consoleHistoryElement=consoleElement.querySelector('pre');consoleHistoryElement.innerHTML="";consoleHistoryElement.style.backgroundColor="#FF906F";setTimeout(function(){consoleHistoryElement.style.transition="background-color 1.5s";consoleHistoryElement.style.backgroundColor="";setTimeout(function() {consoleHistoryElement.style.transition = "";},1500);},0);}console.log(arrayLength + " consoles cleared.");}