javascript 将大字典复制粘贴到 chrome 控制台

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29277964/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 10:19:27  来源:igfitidea点击:

copy paste big dictionary into chrome console

javascriptgoogle-chrome-devtoolsweb-storageinput-history

提问by baszak

what im essentially doing is

我本质上在做的是

var dictionary = [ HERE I PASTE ALMOST 200k ENTRIES ]

and it throws :

它抛出:

Error saving setting with name: consoleHistory, value length: 8613059. Error: Failed to set the 'consoleHistory' property on 'Storage': Setting the value of 'consoleHistory' exceeded the quota.

Ten largest settings: Setting: 'consoleHistory', size: 2872834 Setting: 'previouslyViewedFiles', size: 5462 Setting: 'networkLogColumnsVisibility', size: 378 Setting: 'dataGrid-networkLog-columnWeights', size: 340 Setting: 'userAgent', size: 146 Setting: 'Inspector.drawerSplitViewState', size: 94 Setting: 'selectedAuditCategories', size: 79 Setting: 'sourcesPanelNavigatorSplitViewState', size: 65 Setting: 'sourcesPanelSplitViewState', size: 65 Setting: 'InspectorView.splitViewState', size: 42

使用名称保存设置时出错:consoleHistory,值长度:8613059。错误:无法在“存储”上设置“consoleHistory”属性:设置“consoleHistory”的值超出配额。

十大设置:设置:'consoleHistory',大小:2872834 设置:'previouslyViewedFiles',大小:5462 设置:'networkLogColumnsVisibility',大小:378 设置:'dataGrid-networkLog-columnWeights',大小:340 设置:'userAgent',大小:146 设置:“Inspector.drawerSplitViewState”,大小:94 设置:“selectedAuditCategories”,大小:79 设置:“sourcesPanelNavigatorSplitViewState”,大小:65 设置:“sourcesPanelSplitViewState”,大小:65 : 42

I want to use the dictionary later to search for things and I hit the wall here.

我想稍后使用字典来搜索东西,我在这里撞墙了。

回答by TarranJones

The console history is a record of everything that is executed in the console. so every time you're entering the 200k you are appending that to the history. LocalStorage space cant be adjusted its set to 5MB, but as long as your entry is under that and you are just entering it once then this shouldn't be a problem.

控制台历史记录是在控制台中执行的所有内容的记录。所以每次您输入 200k 时,您都会将其附加到历史记录中。LocalStorage 空间无法调整为 5MB,但只要您的条目在此之下并且您只输入一次,那么这应该不是问题。

You can delete the console history to free up space.
The devtools is just another window so it can be inspected and modified like any other webpage.

您可以删除控制台历史记录以释放空间。
devtools 只是另一个窗口,因此可以像任何其他网页一样对其进行检查和修改。

Open Dev Tools

打开开发工具

  • Select More Tools > Developer Tools from the Chrome Menu.
  • 从 Chrome 菜单中选择更多工具 > 开发者工具。

or

或者

  • Right-click on a page element and selecting "inspect element" in the context menu
  • 右键单击页面元素并在上下文菜单中选择“检查元素”

or

或者

  • Use Ctrl/Cmd+Shift+I
  • 使用 Ctrl/Cmd+Shift+I


Inspect Dev Tools window.


检查开发工具窗口。

  1. In another tab/window navigate to chrome://inspect/#other.
  2. Locate the page which starts with "chrome-devtools://devtools/bundled/"
  3. Click the relevant inspect link.
  1. 在另一个选项卡/窗口中导航到 chrome://inspect/#other。
  2. 找到以“chrome-devtools://devtools/bundled/”开头的页面
  3. 单击相关的检查链接。

This will open another devtools window where you can inspect and modify the devtools.

这将打开另一个 devtools 窗口,您可以在其中检查和修改 devtools。

Remove consoleHistory form LocalStorage

删除 consoleHistory 表单 LocalStorage

Navigate to the newly opened devtools window.

导航到新打开的 devtools 窗口。

Unfortunately typing localStorage.removeItem('consoleHistory');into the console doesn't work;

不幸的是,localStorage.removeItem('consoleHistory');在控制台中输入不起作用;

So you have to do it the long way.

所以你必须做很长的路。

  1. Open "Resources" panel
  2. Expand "Local Storage" either by double clicking "Local Storage" or click the arrow.
  3. Select the called "devtools://devtools" table. (As its full, it may take a while to open)
  4. locate and select the key called 'consoleHistory'
  5. Hit delete or the "X" button.
  1. 打开“资源”面板
  2. 通过双击“本地存储”或单击箭头展开“本地存储”。
  3. 选择名为“devtools://devtools”的表。(因为已满,打开可能需要一段时间)
  4. 找到并选择名为“consoleHistory”的键
  5. 点击删除或“X”按钮。

Note. This answer has been updated to apply to version 46.0.2490.86. some details my have changed since posting. Please leave a comment if this method no longer applies.

笔记。此答案已更新以适用于 46.0.2490.86 版。自发布以来,我已经更改了一些细节。如果此方法不再适用,请发表评论。

If you are using an older versionof chrome and this does not work for you then there is an additional few steps you have to take before using this method. You can find them here.

如果您使用的是旧版本的 chrome 并且这对您不起作用,那么在使用此方法之前您还需要执行一些额外的步骤。您可以在此处找到它们。

you can find your version at chrome://chrome/

你可以在 chrome://chrome/ 找到你的版本

回答by Devin Fields

2018 update:

2018年更新:

Confirmed on Version 65.0.3325.181, you can simply right-click anywhere inside the devtools console and click "Clear console history." It solved the problem for me. I ran into this issue earlier and, having never seen it before, began going through the first couple steps to TarranJones' solution.

在版本 65.0.3325.181 上得到确认,您只需右键单击 devtools 控制台内的任意位置,然后单击“清除控制台历史记录”。它为我解决了这个问题。我之前遇到过这个问题,之前从未见过,开始通过 TarranJones 的解决方案的前几个步骤。

回答by Kyle Chadha

I too ran into this issue (needing to clear consoleHistory) when I maxed out its capacity. In this case clicking on chrome-devtools://de...in inspector would crash the window and trying to delete via localStorage.clear()or localStorage.removeItem()would timeout or be otherwise unsuccessful.

consoleHistory当我最大限度地发挥其容量时,我也遇到了这个问题(需要清除)。在这种情况下,chrome-devtools://de...在检查器中单击会使窗口崩溃并尝试通过删除localStorage.clear()localStorage.removeItem()超时或以其他方式不成功。

My solution was deleting the localStorage data files themselves.

我的解决方案是删除 localStorage 数据文件本身。

On a mac, the instructions are:

在 Mac 上,说明是:

cd ~/Library/Application\ Support/Google/Chrome/Default/Local\ Storage
rm chrome-devtools_devtools_0.localstorage
rm chrome-devtools_devtools_0.localstorage-journal

A quick google search suggests on Windows it's %LocalAppData%\Google\Chrome\User Data\Default\Local Storage, but you may need to double check.

快速谷歌搜索在 Windows 上建议它是%LocalAppData%\Google\Chrome\User Data\Default\Local Storage,但您可能需要仔细检查。