Skip to content

How to Debug Database Issue

tophf edited this page Mar 29, 2023 · 2 revisions

Find out which database is activated

For historical reason, Stylus uses two databases to store your data. When one is down, it switches to the other one automatically. When this happens, you will find that all your styles disappeared.

  1. Open the style manager

  2. Open the devtool by pressing F12

  3. Switch to the Console tab

  4. Copy-paste following commands and press Enter, then expand the result:

    chrome.storage.local.get(["dbInChromeStorage", "dbInChromeStorageReason"], console.log)
  5. If it says true then you are using chromeStorageDB, it may also come with a reason.

    If it says false then you are using indexedDB.

Check the content of indexedDB (Chrome)

  1. Open the style manager
  2. Open the devtool console by pressing F12
  3. Switch to the Application tab
  4. At the left panel, expand IndexedDB > stylish > styles

If the database contains data:
image

Check the content of indexedDB (Firefox)

  1. Open the style manager
  2. Open the storage panel by pressing Shift> + F9
  3. At the left panel, expand Indexed DB > moz-extension://... > stylish (default) > styles

If the database contains data:
image

Check the content of chromeStorageDB

  1. Open the style manager

  2. Open the devtool console by pressing F12

  3. Switch to the Console tab

  4. Copy-paste the following command and press Enter:

    chrome.storage.local.get(r => {
      console.log(Object.entries(r).map(([k, v]) => k.startsWith("style-") && v).filter(Boolean));
    });

If the database contains data:
image

Switch the database

Sometimes your data are still there but you can't see it because the wrong database is activated. In this case, you just have to switch the database.

  1. Open the style manager

  2. Open the devtool by pressing F12

  3. Switch to the Console tab

  4. Copy-paste the command and press Enter:

    • Switch to IndexedDB:

      chrome.storage.local.set({dbInChromeStorage: false});
    • Switch to chromeStorageDB:

      chrome.storage.local.set({dbInChromeStorage: true, dbInChromeStorageReason: "switched manually"});
  5. Restart the browser