迁移代码片段后无法打开DevTools

发布于 2025-02-13 18:57:56 字数 382 浏览 1 评论 0原文

我认为我在Edge(当前Ver 103)中损坏了我的主要配置文件,同时从另一个配置文件迁移代码片段。我使用InspectorFrontendHost.getPreferences / setPreference < / code>来迁移我的摘要,并且看起来正常。

但是,DevTools不会使用F12,CTRL-SHFT-I或右键单击重新打开。 我可以看到一个DevTools选项卡出现在浏览器任务管理器中,但是没有出现窗口或选项卡。

DevTools在我的其他配置文件中在同一台机器上工作正常,即使我同时在不同的Windows上打开了两个配置文件。

我可以强制重置边缘配置文件的部分,该部分存储片段而不会丢失其余的轮廓?我在工作机器上,因此无法获得高架特权。 谢谢

I think I have corrupted my main profile in Edge (current Ver 103) whilst migrating code snippets from another profile. I used InspectorFrontendHost.getPreferences / setPreference to migrate my snippets and it appeared to work fine.

However DevTools will not reopen using F12, CTRL-SHFT-i or right click.
I can see a DevTools tab appear in Browser Task Manager, but no window or tab appears.

DevTools works fine on the same machine in my other profile, even if I have both profiles open in different windows at the same time.

Can I force a reset of the part of the Edge profile that stores snippets without losing the rest of the profile? I am on a work machine so don't have access to elevated priviledges.
Thank you

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

旧时模样 2025-02-20 18:57:56

不幸的是,我无法复制这个问题。我尝试了相同的功能来导出/导入片段,但是我的DevTools仍然成功启动。由于DevTools选项卡在浏览器任务管理器中,因此您可以双击选项卡,以查看它是否无意间最小化。

但是我恐怕您不仅可以重置存储片段的边缘配置文件的一部分。我建议您进行浏览器重置以查看它是否有效。您可以转到设置 - &gt;重置设置 - &GT;还原设置为其默认值。

顺便说一句,您的摘要位于您的个人资料路径下的“偏好”文件。您可以转到Edge://版本以找到您的个人资料路径。

Unfortunately, I was unable to reproduce this issue. I tried the same function to export/import snippets, but my devtools was still successfully launched. Since a devtools tab is in the browser task manager, you can double click on the tab to see whether it is just unintentionally minimized.

But I'm afraid you cannot only reset the part of your Edge profile that stores snippet. I suggest you doing a browser reset to see if it works. You can go to Settings --> Reset settings --> Restore settings to their default values.

By the way, your snippets are located at a "Preference" file under your profile path. You can go to edge://version to find your profile path.

[浮城] 2025-02-20 18:57:56

我也有同样的问题(即使在浏览器重新启动后,我也无法打开DevTools)。原因是我首先将偏好设置为错误的价值(而不是包含json的字符串 - 我将其包裹到另一个字符串字面的字符串 - 字符串的lenght大约为127KB)。也许是因为弦长的长度,因为浏览器像JSON一样解析它,它由一个长长的文字组成。 来完成此操作

InspectorFrontendHost.setPreference("scriptSnippets",JSON.stringify(text)

我通过解决问题

  1. - 您需要:退出浏览器(因为浏览器会不断使用首选项重写文件)
  2. 用名称 preverences - files - 实际上是json修复文件,尽管没有扩展。如果您知道如何修复JSON做到这一点 - 如果您不这样做,则只需在某个地方复制“ Scriptsnippets”的值,以免丢失所有片段!!!保存破碎的摘要后的快速修复 - 只需为属性“ scriptsnippets”设置“空刺”字面的“”),

以找到文件的路径,并找到下面的url并找到行 profile profile path path (其OS文件系统中包含首选项的目录中的路径 json文件)

chrome://version

,以防万一,

如果要下载所有片段为JSON文件:

// get string in json format of all snippets
InspectorFrontendHost.getPreferences(preferencesList=>{
    // make blob from json
    const snippets_blob = new Blob([preferencesList.scriptSnippets],{type:'application/json'});
    
    function saveBlobToFile(blob, filename) {
        const url = URL.createObjectURL(blob);
        const a = document.createElement('a');
        a.href = url;
        a.download = filename;
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
        URL.revokeObjectURL(url);
    }
    
    saveBlobToFile(snippets_blob, `snippets_from_chrome_${new Date().toLocaleDateString().replaceAll('/','_')}.json`)
});

从JSON上传摘要文件使用:

const input = document.createElement('input');
input.type = 'file';
input.style = 'position: fixed; z-index: 100;';
document.body.prepend(input); // input will appear at initial devtool window that was opened first

input.addEventListener('change',function (event) {
    const file = event.target.files[0];
    file.text().then(text=>{
        InspectorFrontendHost.setPreference("scriptSnippets",text);
    })
})

I have same issue (i cant open devtools even after browser restart). The reason was that i set wrong value to the preferences at first place (instead of string that contain json - i wrapped it to another string literal - lenght of string was around 127kb). Maybe it was because of length of string because browser parse it like json that consist from one long sting literal. I done it via

InspectorFrontendHost.setPreference("scriptSnippets",JSON.stringify(text)

To fix problem - you need:

  1. quit browser (because browser constantly rewrite file with preferences)
  2. fix manually file with name Preferences - file in fact json although extension is absence on it. If you know how to fix json do it - if you dont, just copy value of "scriptSnippets" somewhere to not lost all your snippets!!! As quick fix after you saved broken snippets - just clear value (just try set empty sting literal "") for the property "scriptSnippets"

To find the path to the file use url below and find line Profile Path (its path in your os filesystem to directory that contain Preferences json file)

chrome://version

and just in case couple snippets

if you want to download all snippets as json file:

// get string in json format of all snippets
InspectorFrontendHost.getPreferences(preferencesList=>{
    // make blob from json
    const snippets_blob = new Blob([preferencesList.scriptSnippets],{type:'application/json'});
    
    function saveBlobToFile(blob, filename) {
        const url = URL.createObjectURL(blob);
        const a = document.createElement('a');
        a.href = url;
        a.download = filename;
        document.body.appendChild(a);
        a.click();
        document.body.removeChild(a);
        URL.revokeObjectURL(url);
    }
    
    saveBlobToFile(snippets_blob, `snippets_from_chrome_${new Date().toLocaleDateString().replaceAll('/','_')}.json`)
});

to upload snippets from json file use:

const input = document.createElement('input');
input.type = 'file';
input.style = 'position: fixed; z-index: 100;';
document.body.prepend(input); // input will appear at initial devtool window that was opened first

input.addEventListener('change',function (event) {
    const file = event.target.files[0];
    file.text().then(text=>{
        InspectorFrontendHost.setPreference("scriptSnippets",text);
    })
})
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文