保存/导出Chrome的JavaScript控制台输入历史记录 [英] Save / export Chrome's JavaScript console input history

查看:383
本文介绍了保存/导出Chrome的JavaScript控制台输入历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是否可以在Google Chrome中保存或导出JavaScript控制台 input 的历史记录(控制台历史记录)?我不想保存输出或错误,因此将鼠标悬停在控制台框上,右键单击并选择Save as...并不是解决方案.我不想每次使用箭头键向上滚动并复制并粘贴内容.

Is there anyway that I can save or export the history of JavaScript console input (console history) in Google Chrome? I'm not looking to save the output or the errors, so hovering my mouse over the console box, right-clicking, and selecting Save as... is not the solution. I don't want to have to scroll up with the arrow keys and copy-and-paste the contents each time.

推荐答案

我想出了一个似乎可行的怪异解决方案:

I figured out a weird solution that seems to work:

  • 打开Chrome开发者工具(按 CTRL + SHIFT + J )

如果停靠了开发人员工具窗口,则将其停靠在一个单独的窗口中(打开 菜单以选择停靠选项)

If the developer tools window is docked, undock into a separate window (open the menu to choose docking option)

在开发人员工具窗口中,按 CTRL + SHIFT + J ,这将打开开发人员工具窗口 用于开发者工具窗口!

Inside the developer tools window, press CTRL + SHIFT + J which will open a developer tools window for the developer tools window!

在第二个开发人员工具窗口内,在控制台内输入以下命令:
localStorage.getItem("consoleHistory")

Inside the second developer tools window, enter the following command inside console:
localStorage.getItem("consoleHistory")

这应该打印控制台历史记录,在控制台内部以JSON编码.您可以使用以下命令将JSON解码为数组:

This should print the console history, encoded as JSON inside the console. You can decode the JSON into an array using this command:

JSON.parse(localStorage.getItem("consoleHistory"))

或使用以下命令将JSON复制到剪贴板:

Or copy the JSON to clipboard using:

copy(localStorage.getItem("consoleHistory"))

这篇关于保存/导出Chrome的JavaScript控制台输入历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆