Created
December 25, 2010 02:04
-
-
Save playpauseandstop/754619 to your computer and use it in GitHub Desktop.
Simple script to clean (remove) all thumbnails for sites placed at "Most visited" section of Google Chrome or Chromium new page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Simple script to clean (remove) all thumbnails for sites placed at "Most | |
# visited" section of Google Chrome or Chromium new page. | |
# | |
# Installation | |
# ============ | |
# | |
# Store this script somewhere in your ``$PATH`` (like ``~/bin/`` or | |
# ``/usr/local``). | |
# | |
# Requirements | |
# ============ | |
# | |
# * Python 2.5 or higher | |
# | |
# Usage | |
# ===== | |
# | |
# $ clean-chrome-thumbnails.py | |
# | |
import os | |
import sqlite3 | |
import sys | |
CHROME_FILE = os.path.expanduser('~/.config/google-chrome/Default/Top Sites') | |
CHROMIUM_FILE = CHROME_FILE.replace('google-chrome', 'chromium') | |
def clean_thumbnails(filename): | |
""" | |
Connect to sqlite3 database where Google Chrome or Chromium store | |
information about most visited sites and blanks all ``thumbnail`` fields | |
in ``thumbnails`` table. | |
""" | |
if not os.path.isfile(filename): | |
return | |
name = filename.split(os.path.sep)[-3].replace('-', ' ').title() | |
print('Clean thumbnails of Most Visited Sites for %s.') % name | |
conn = sqlite3.connect(filename) | |
sql = 'UPDATE thumbnails SET thumbnail = null;' | |
cursor = conn.cursor() | |
cursor.execute(sql) | |
conn.commit() | |
cursor.close() | |
print('All OK!') | |
def main(): | |
""" | |
Run clean thumbnails function only if Google Chrome or Chromium top | |
sites database found at disk. | |
""" | |
if not os.path.isfile(CHROME_FILE) and not os.path.isfile(CHROMIUM_FILE): | |
print('Looks like you have not Google Chrome or Chromium installed ' \ | |
'on your machine.') | |
sys.exit(1) | |
clean_thumbnails(CHROME_FILE) | |
clean_thumbnails(CHROMIUM_FILE) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment