Skip to content

Instantly share code, notes, and snippets.

@f1u77y
Created May 23, 2017 07:33
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save f1u77y/715f0dd03fc18039a6549de557370b97 to your computer and use it in GitHub Desktop.
Save f1u77y/715f0dd03fc18039a6549de557370b97 to your computer and use it in GitHub Desktop.
Export styles from Stylish for Firefox
#! /usr/bin/env python3
import os.path
import glob
import sqlite3
import json
def main():
styles_glob = os.path.expanduser('~/.mozilla/firefox/*.default/stylish.sqlite')
styles_path = glob.glob(styles_glob)[0]
conn = sqlite3.connect(styles_path)
c = conn.cursor()
styles = []
for row in c.execute('SELECT * FROM styles'):
_id, url, updUrl, md5Url, name, code, enabled, origCode, idUrl, bg, origMd5 = row
styles.append({
'method': 'saveStyle',
'name': name,
'enabled': bool(enabled),
'sections': [{
'code': code,
}],
'updateUrl': updUrl or None,
'md5Url': md5Url or None,
'url': url or None,
'originalMd5': origMd5 or None,
'id': _id,
})
conn.close()
with open('stylus.json', 'w') as stylus:
json.dump(styles, stylus)
if __name__ == '__main__':
main()
@ExE-Boss
Copy link

ExE-Boss commented May 23, 2017

I’ve created a fork that works on Windows (but not on Linux):
https://gist.github.com/ExE-Boss/22baa3558972195d4edc3794d4f7ddb8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment