Last active
May 4, 2017 19:07
-
-
Save za3k/6337391 to your computer and use it in GitHub Desktop.
Copy chromium's URL history to a logfile, and delete the original history if possible (e.g. if chromium is not running). Logfile is in the line-based format "<windows timestamp>|<url>".
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
#!/bin/bash | |
DATABASE=$(mktemp) | |
CHROMEDB=~/.config/chromium/Default/History | |
ISLOCKED=$(sqlite3 ~/.config/chromium/Default/History "SELECT COUNT(*) from urls" 2>&1 1>/dev/null) | |
EXPORT_FILE=~/.visited_urls | |
if [ ! -f "${CHROMEDB}" ] | |
then | |
echo "Chrome database \"$CHROMEDB\" is missing. This may be normal behavior if the history is cleared." | |
exit 0 | |
fi | |
if [ "$ISLOCKED" ] | |
then | |
echo "Locked, using a copy" | |
cp "${CHROMEDB}" "${DATABASE}.db" | |
else | |
mv "${CHROMEDB}" "${DATABASE}.db" | |
fi | |
sqlite3 "${DATABASE}.db" "SELECT MAX(visits.visit_time) as visit_time, urls.url as url FROM urls INNER JOIN visits ON urls.id = visits.url GROUP BY urls.id" >> "${DATABASE}.urls" | |
rm "${DATABASE}.db" | |
cat "${DATABASE}.urls" | tee -a "${EXPORT_FILE}" | |
rm "${DATABASE}.urls" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment