4

如何清除 Rails Web 控制台?

更好的错误 Web 控制台的图像链接

在此处输入图像描述

4

1 回答 1

0

我开发了一些 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.");}
于 2016-04-19T18:18:40.243 回答