4

How can I clear rails web console?

Image link of better errors web console

enter image description here

Nikos
  • 3,267
  • 1
  • 25
  • 32
mohitmun
  • 5,379
  • 3
  • 18
  • 16

1 Answers1

0

I have developed some JavaScript that can be shoved into a bookmarklet and used in the browser to clear the live console.

Verbose Code

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.");
}

Bookmarklet

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.");}
Pysis
  • 1,452
  • 2
  • 17
  • 31