Access GM_getValue outside of script

风格不统一 提交于 2019-12-06 11:23:16

问题


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.


回答1:


  • 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.



来源:https://stackoverflow.com/questions/42775277/access-gm-getvalue-outside-of-script

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!