Where does GM_setValue store data?

不问归期 提交于 2019-12-03 00:32:45

In Tampermonkey, GM_setValue() data is stored in a LevelDB database that can be found in the User Data Directory tree.

Once in Chrome's "User Data Directory" (EG: C:\Users\USER_JOE\AppData\Local\Google\Chrome\User Data\Default\),

navigate to the Local Extension Settings\dhdgffkkebhmkfjojejmpbldmpobfkfo folder.

(gcalenpjmijncebpfijmoaglllgpjagf for the Tampermonkey Beta.)

There you will find a LevelDB database, usually named CURRENT. You can manipulate it with tools like LevelDB JSON, but external support for LevelDB currently appears to be spotty and I did not find any working tools for Windows yet (might have to compile your own).

You can also use the Chrome Storage Area Explorer extension to explore the data.

As of Tampermonkey 4.3.6, you can see an individual script's data with the Storage tab in the built-in script editor:




OLD, Pre November-ish 2015:

  • Before, about November 2015, data was stored in a Web SQL database in databases\chrome-extension_dhdgffkkebhmkfjojejmpbldmpobfkfo_0.

Once you have navigated to the correct folder, you will typically see two files. On my machine, they are currently just named 4 and 6. These are both SQLite files (the backend for Chrome's Web SQL implementation) and can be inspected with a SQLite viewer/utility.

The (normally) larger file, 6 on my machine, is a somewhat disturbing list of 94-thousand userscripts! I'm not sure what purpose it serves, but haven't investigated it much.

The smaller file (initially, at least), 4 on my machine, is where all the information about/for your userscripts is kept. This includes any data set by GM_setValue().


For example, if I install and run this userscript:

// ==UserScript==
// @name     _GM_setValue demo
// @match    https://stackoverflow.com/questions/*
// @grant    GM_setValue
// ==/UserScript==

GM_setValue ('foo', 'bar');


And then I inspect the config table in file 4, I will see four entries like this:


The one you want is the @st row. Notice how it has the GM_setValue data encoded? :

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