在脚本之外访问 GM_getValue [英] Access GM_getValue outside of script

查看:35
本文介绍了在脚本之外访问 GM_getValue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上是问题标题.这将使我受益匪浅.我希望能够在我的用户脚本之外访问 GM_getValue 以进行调试,或者至少访问值和名称本身.

我使用的是 Windows 10 上的 Chrome.

解决方案

  • 最新的 Tampermonkey 测试版(以及最终正常的 Tampermonkey)在 Storage 标签的仪表板脚本编辑器中显示 GM 值.

  • 可视化方法:使用

<小时>
  • 在控制台中转储:

    一次性设置:在 devtools - Sources - Snippets 子面板中添加新代码 snippet 并保存:

    function dumpGM_data(scriptName) {chrome.storage.local.get(空,数据=> {const UID = Object.keys(data).find(k => k.startsWith('@uid#') &&数据[k].value == 脚本名);如果(UID)console.log(data[UID.replace('@uid', '@st')].value.data);});}

    1. 打开 Tampermonkey 仪表板页面并通过 F12CtrlShifti
    2. 调用 devtools
    3. 打开并运行该代码段:CtrlEnter - 在您关闭仪表板页面之前,它将一直可用
    4. 在控制台中调用它:

      dumpGM_data('SE 悬停预览')

<小时>
  • 直接检查/转储/编辑数据库文件:

    使用您可以在 Chrome 用户配置文件目录Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfoLocal Extension Settings/gcalenpjmijncebpfijmoaglllgpjagf 中,用于 Tampermonkey 测试版.

Basically the question title. It would greatly benefit me. I want to be able to access GM_getValue outside of my userscript for debugging purposes, or, at the very least, the values and names themselves.

I am in Chrome on Windows 10.

解决方案

  • Latest Tampermonkey beta (and eventually normal Tampermonkey) displays the GM values in its dashboard script editor in Storage tab.

  • Visual method: use Storage Area Explorer extension:

    1. Open the Tampermonkey dashboard page and invoke devtools by F12 or CtrlShifti
    2. In Storage Area Explorer panel scroll to the bottom to find the @uid# of your script by name, then find its data in @st# key with that UID:


  • Dumping in the console:

    One-time setup: add a new code snippet in devtools - Sources - Snippets subpanel and save it:

    function dumpGM_data(scriptName) {
        chrome.storage.local.get(null, data => {
            const UID = Object.keys(data).find(k => k.startsWith('@uid#') &&
                                                    data[k].value == scriptName);
            if (UID)
                console.log(data[UID.replace('@uid', '@st')].value.data);
        });
    }
    

    1. Open the Tampermonkey dashboard page and invoke devtools by F12 or CtrlShifti
    2. open and run that snippet: CtrlEnter - it'll be usable until you close the dashboard page
    3. invoke it in the console:

      dumpGM_data('SE Preview on hover')
      


  • Inspect/dump/edit the database file directly:

    Use any LevelDB tool you can find (or compile one yourself) on the ldb database file under Chrome user profile directory in Local Extension Settings/dhdgffkkebhmkfjojejmpbldmpobfkfo or Local Extension Settings/gcalenpjmijncebpfijmoaglllgpjagf for Tampermonkey beta.

这篇关于在脚本之外访问 GM_getValue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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