Compare commits
5 Commits
2fcb4eae1e
...
5ebdb19cc0
Author | SHA1 | Date |
---|---|---|
Michele Guerini Rocco | 5ebdb19cc0 | |
Michele Guerini Rocco | 2c62ee1704 | |
Michele Guerini Rocco | 6a008f26be | |
Michele Guerini Rocco | d131fc510e | |
Michele Guerini Rocco | e16a6e42d6 |
55
Main.hs
55
Main.hs
|
@ -13,8 +13,9 @@ import qualified Database.LevelDB as L
|
|||
import qualified Database.LevelDB.Streaming as LS
|
||||
|
||||
-- Error handling
|
||||
import Control.Exception as BE
|
||||
import Control.Monad.Catch as CE
|
||||
import Control.Exception as BE
|
||||
import Control.Monad.Catch as CE
|
||||
import qualified System.Exit as E
|
||||
|
||||
-- Configuration
|
||||
import qualified Options.Applicative as O
|
||||
|
@ -27,6 +28,10 @@ import qualified Data.Text as T
|
|||
import qualified Data.Text.IO as T
|
||||
import qualified Data.ByteString as B
|
||||
|
||||
-- Version information
|
||||
import qualified Paths_bisc as Bisc
|
||||
import Data.Version (showVersion)
|
||||
|
||||
-- Misc
|
||||
import Data.List (nub)
|
||||
import Data.Maybe (mapMaybe)
|
||||
|
@ -49,7 +54,8 @@ data Settings = Settings
|
|||
|
||||
-- | Command line options
|
||||
data Options = Options
|
||||
{ dryRun :: Bool -- ^ don't delete anything
|
||||
{ version :: Bool -- ^ print version number
|
||||
, dryRun :: Bool -- ^ don't delete anything
|
||||
, configPath :: FilePath -- ^ config file path
|
||||
}
|
||||
|
||||
|
@ -59,6 +65,11 @@ cliParser defConfig = O.info (O.helper <*> parser) infos
|
|||
where
|
||||
parser = Options
|
||||
<$> O.switch
|
||||
( O.long "version"
|
||||
<> O.short 'v'
|
||||
<> O.help "Print the version number and exit"
|
||||
)
|
||||
<*> O.switch
|
||||
( O.long "dry-run"
|
||||
<> O.short 'n'
|
||||
<> O.help ("Don't actually remove anything, "<>
|
||||
|
@ -122,24 +133,32 @@ main = do
|
|||
defConfig <- D.getXdgDirectory D.XdgConfig ("bisc" </> "bisc.conf")
|
||||
opts <- O.execParser (cliParser defConfig)
|
||||
|
||||
when (version opts) $ do
|
||||
putStrLn ("bisc " <> showVersion Bisc.version)
|
||||
E.exitSuccess
|
||||
|
||||
run <- runAction <$> loadSettings opts
|
||||
run "Cookies" deleteCookies
|
||||
run "QuotaManager" deleteQuotaOrigins
|
||||
run "IndexedDB" deleteIndexedDB
|
||||
run "LocalStorage" deleteLocalStorage
|
||||
run "SessionStorage" deleteSessionStorage
|
||||
numFailures <- sum <$> mapM (uncurry run) actions
|
||||
|
||||
if numFailures == 0
|
||||
then E.exitSuccess
|
||||
else do
|
||||
putStrLn ("\nwarning: " <> show numFailures <> " actions have failed")
|
||||
E.exitWith (E.ExitFailure numFailures)
|
||||
|
||||
|
||||
-- | Runs an 'Action' and pretty-prints the results
|
||||
runAction :: Settings -> Text -> Action Result -> IO ()
|
||||
runAction :: Settings -> Text -> Action Result -> IO Int
|
||||
runAction settings name x = do
|
||||
a <- BE.try $ runExceptT (runReaderT x settings)
|
||||
case a of
|
||||
Right (Right res) -> printResult res
|
||||
Right (Left msg) -> printFailed msg
|
||||
Left (err :: BE.IOException) -> printFailed (T.pack $ BE.displayException err)
|
||||
Right (Right res) -> printResult res >> return 0
|
||||
Right (Left msg) -> printFailed msg >> return 1
|
||||
Left (err :: BE.IOException) ->
|
||||
printFailed (T.pack $ BE.displayException err) >> return 1
|
||||
where
|
||||
printFailed msg = T.putStrLn ("- " <> name <> " cleaning failed:\n " <> msg)
|
||||
printFailed msg =
|
||||
T.putStrLn ("- " <> name <> " cleaning failed:\n " <> msg)
|
||||
printResult (n, bad)
|
||||
| n > 0 = do
|
||||
T.putStrLn ("- " <> name <> ": " <> verb <>
|
||||
|
@ -153,6 +172,16 @@ runAction settings name x = do
|
|||
|
||||
-- * Cleaning actions
|
||||
|
||||
-- | List of actions and their names
|
||||
actions :: [(Text, Action Result)]
|
||||
actions =
|
||||
[ ("Cookies", deleteCookies)
|
||||
, ("QuotaManager", deleteQuotaOrigins)
|
||||
, ("IndexedDB", deleteIndexedDB)
|
||||
, ("LocalStorage", deleteLocalStorage)
|
||||
, ("SessionStorage", deleteSessionStorage)
|
||||
]
|
||||
|
||||
-- | Deletes records in the Cookies database
|
||||
deleteCookies :: Action Result
|
||||
deleteCookies = do
|
||||
|
|
36
README.md
36
README.md
|
@ -2,29 +2,28 @@
|
|||
|
||||
### A small tool that clears cookies (and more)
|
||||
|
||||
Websites can store unwanted data using all sorts of methods: besides
|
||||
the usual cookies, there are also the local and session storage, the
|
||||
IndexedDB API and more caches as well.
|
||||
Websites can store unwanted data using all sorts of methods: besides the usual
|
||||
cookies, there are also the local and session storage, the IndexedDB API and
|
||||
more caches as well.
|
||||
|
||||
bisc will try to go through each of them and remove all information from
|
||||
websites that are not explicitly allowed (ie. a whitelist of domains).
|
||||
It was created for qutebrowser, but it actually supports the storage
|
||||
format used by Chromium-based browsers, which (sadly) means almost
|
||||
every one nowadays.
|
||||
It was created for qutebrowser, but it actually supports the storage format
|
||||
used by Chromium-based browsers, which (sadly) means almost every one nowadays.
|
||||
|
||||
## Installation
|
||||
|
||||
bisc is a Haskell program available on [Hackage][hackage] and can
|
||||
be installed with one of the Haskell package managers. For
|
||||
example, with [cabal-install][cabal] you would do
|
||||
bisc is a Haskell program available on [Hackage][hackage] and can be installed
|
||||
with one of the Haskell package managers. For example, with
|
||||
[cabal-install][cabal] you would do
|
||||
```
|
||||
cabal install bisc
|
||||
```
|
||||
and similarly for [stack][stack].
|
||||
|
||||
Alternatively, if you are using Nix or NixOS, bisc is available
|
||||
under the attribute `haskellPackages.bisc`. It should also be in
|
||||
the Nix binary cache so you don't have to build from source.
|
||||
Alternatively, if you are using Nix or NixOS, bisc is available under the
|
||||
attribute `haskellPackages.bisc`. It should also be in the Nix binary cache so
|
||||
you don't have to build from source.
|
||||
|
||||
Finally, statically compiled binaries can be found in the
|
||||
[releases](/git/rnhmjoj/bisc/releases).
|
||||
|
@ -35,9 +34,8 @@ Finally, statically compiled binaries can be found in the
|
|||
|
||||
## Configuration
|
||||
|
||||
The bisc configuration file is `$XDG_CONFIG_HOME/bisc/bisc.conf`.
|
||||
It allows to change the paths of the QtWebEngine/Chromium
|
||||
directory and the whitelist file.
|
||||
The bisc configuration file is `$XDG_CONFIG_HOME/bisc/bisc.conf`. It allows to
|
||||
change the paths of the QtWebEngine/Chromium directory and the whitelist file.
|
||||
The default settings are:
|
||||
```
|
||||
whitelist-path = "$(XDG_CONFIG_HOME)/qutebrowser/whitelists/cookies"
|
||||
|
@ -49,16 +47,16 @@ using the `--config` command line option.
|
|||
|
||||
## Usage
|
||||
|
||||
Create an empty whitelist file and write the domains of the
|
||||
allowed cookies, one per line.
|
||||
- Create an empty whitelist file and write the domains of the allowed cookies,
|
||||
one per line.
|
||||
Eg.
|
||||
```
|
||||
.example.com
|
||||
example.com
|
||||
```
|
||||
|
||||
Run `bisc` to delete all non-whitelisted data from qutebrowser.
|
||||
Run `bisc --dry-run` to see what would be deleted without actually doing it.
|
||||
- Run `bisc --dry-run` to see what would be deleted without actually doing it.
|
||||
- Run `bisc` to delete all non-whitelisted data from qutebrowser.
|
||||
|
||||
Note that running bisc while the browser is open is not safe: this means it
|
||||
could possibly **corrupt** the databases. Hoever, corruption in the sqllite
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: bisc
|
||||
version: 0.3.1.0
|
||||
version: 0.4.0.0
|
||||
synopsis: A small tool that clears cookies (and more).
|
||||
description:
|
||||
|
||||
|
@ -29,6 +29,10 @@ source-repository head
|
|||
type: git
|
||||
location: https://maxwell.ydns.eu/git/rnhmjoj/bisc
|
||||
|
||||
flag static
|
||||
default: False
|
||||
description: Create a statically-linked binary
|
||||
|
||||
executable bisc
|
||||
main-is: Main.hs
|
||||
build-depends: base ==4.* , selda ==0.*,
|
||||
|
@ -40,4 +44,5 @@ executable bisc
|
|||
optparse-applicative
|
||||
default-language: Haskell2010
|
||||
ghc-options: -Wall
|
||||
extra-libraries: snappy stdc++
|
||||
if flag(static)
|
||||
extra-libraries: snappy stdc++
|
||||
|
|
46
default.nix
46
default.nix
|
@ -10,38 +10,32 @@ let
|
|||
basepkgs = import nixpkgs { inherit system; };
|
||||
pkgs = if static then basepkgs.pkgsStatic else basepkgs.pkgs;
|
||||
|
||||
f = { mkDerivation, base, bytestring, configurator, data-default
|
||||
, directory, exceptions, filepath, leveldb-haskell, mtl, selda
|
||||
, selda-sqlite, lib, text, optparse-applicative
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "bisc";
|
||||
version = "0.3.0.0";
|
||||
src = ./.;
|
||||
isLibrary = false;
|
||||
isExecutable = true;
|
||||
executableHaskellDepends = [
|
||||
base bytestring configurator data-default directory exceptions
|
||||
filepath leveldb-haskell mtl selda selda-sqlite text
|
||||
optparse-applicative
|
||||
];
|
||||
executableSystemDepends = [ pkgs.snappy ];
|
||||
buildFlags = lib.optionals static [
|
||||
"--ld-option=-lstdc++"
|
||||
"--ld-option=-lsnappy"
|
||||
];
|
||||
homepage = "https://maxwell.ydns.eu/git/rnhmjoj/bisc";
|
||||
description = "A small tool that clears cookies (and more)";
|
||||
license = lib.licenses.gpl3;
|
||||
};
|
||||
|
||||
ghc = if static then pkgs.haskell.packages.integer-simple.ghc8104
|
||||
else if compiler == "default" then pkgs.haskellPackages
|
||||
else pkgs.haskell.packages.${compiler};
|
||||
|
||||
variant = if doBenchmark then pkgs.haskell.lib.doBenchmark else pkgs.lib.id;
|
||||
|
||||
drv = variant (ghc.callPackage f {});
|
||||
drv = variant (override (ghc.callPackage ./bisc.nix {}));
|
||||
|
||||
override = drv: pkgs.haskell.lib.overrideCabal drv (old: with pkgs.lib; {
|
||||
buildTools = [ pkgs.installShellFiles ];
|
||||
configureFlags = optional static "-f static";
|
||||
buildFlags = optionals static [
|
||||
"--ld-option=-lstdc++"
|
||||
"--ld-option=-lsnappy"
|
||||
];
|
||||
postInstall = ''
|
||||
# generate completion
|
||||
$out/bin/bisc --bash-completion-script "$out/bin/bisc" > bisc.bash
|
||||
$out/bin/bisc --fish-completion-script "$out/bin/bisc" > bisc.fish
|
||||
$out/bin/bisc --zsh-completion-script "$out/bin/bisc" > bisc.zsh
|
||||
|
||||
installShellCompletion bisc.{bash,fish,zsh}
|
||||
installManPage man/*.[0-9]
|
||||
'';
|
||||
postFixup = optionalString static "rm -r $out/nix-support";
|
||||
});
|
||||
|
||||
in
|
||||
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
.TH bisc 1 "Semptember 7, 2021" "bisc 0.4.0" "User Commands"
|
||||
|
||||
.SH NAME
|
||||
bisc - a small tool that clears cookies (and more)
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B bisc
|
||||
.RI [ option ]
|
||||
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
Websites can store unwanted data using all sorts of methods: besides the usual
|
||||
cookies, there are also the local and session storage, the IndexedDB API and
|
||||
more caches as well.
|
||||
.PP
|
||||
Bisc will try to go through each of them and remove all information from
|
||||
websites that are not explicitly allowed (ie. a whitelist of domains).
|
||||
It was created for qutebrowser, but it actually supports the storage format
|
||||
used by Chromium-based browsers, which (sadly) means almost every one nowadays.
|
||||
|
||||
.SH USAGE
|
||||
.IP \(bu 2
|
||||
Create an empty whitelist file (see the FILES section) and write the domains of
|
||||
the allowed cookies, one per line. For example:
|
||||
.IP
|
||||
.nf
|
||||
\fC
|
||||
\&.example.com
|
||||
example.com
|
||||
\fR
|
||||
.fi
|
||||
.IP \(bu 2
|
||||
Run \fCbisc --dry-run\fR to see what would be deleted without actually
|
||||
doing it.
|
||||
.IP \(bu 2
|
||||
Run \fCbisc\fR to delete all non-whitelisted data from qutebrowser.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.BR -c ","\ --config\ FILE
|
||||
Use FILE as the configuration file.
|
||||
.TP
|
||||
.BR -n ","\ --dry-run
|
||||
Don't actually remove anything, just show what would be done.
|
||||
.TP
|
||||
.BR -h ","\ --help
|
||||
Show the program information and help screen.
|
||||
|
||||
.SH FILES
|
||||
.TP
|
||||
.I $XDG_CONFIG_HOME/bisc/bisc.conf
|
||||
Bisc configuration
|
||||
.TP
|
||||
.I $XDG_CONFIG_HOME/qutebrowser/whitelists/cookies
|
||||
Domain whitelist
|
||||
.TP
|
||||
.I $XDG_DATA_HOME/qutebrowser/webengine
|
||||
Chromium/QtWebEngine state directory
|
||||
.PP
|
||||
Note: when the variable $XDG_CONFIG_HOME or $XDG_DATA_HOME is not set,
|
||||
$HOME/.config and $HOME/.local/share respectively, will be used instead.
|
||||
|
||||
.SH SEE ALSO
|
||||
\fBbisc.conf\fR(5) for the bisc configuration file
|
||||
|
||||
.SH AUTHORS
|
||||
Copyright © 2021 Michele Guerini Rocco.
|
||||
.TP 0
|
||||
Released under the GPL, version 3 or greater.
|
||||
This software carries no warranty of any kind.
|
|
@ -0,0 +1,49 @@
|
|||
.TH bisc.conf 5 "Semptember 7, 2021" "bisc 0.4.0"
|
||||
|
||||
.SH NAME
|
||||
bisc.conf - bisc configuration file
|
||||
|
||||
.SH SYNOPSIS
|
||||
|
||||
The bisc configuration file, found at the following locations, unless specified
|
||||
via the \fC-c\fR command line option:
|
||||
.IP \(bu 3
|
||||
$XDG_CONFIG_HOME/bisc/bisc.conf,
|
||||
.IP \(bu 3
|
||||
$HOME/.config/bisc/bisc.conf (when $XDG_CONFIG_HOME is not set)
|
||||
|
||||
.SH DESCRIPTION
|
||||
.PP
|
||||
The bisc.conf file allows to change the default location of a couple of files
|
||||
used by bisc.
|
||||
|
||||
.SH OPTIONS
|
||||
|
||||
.TP 4
|
||||
.BR "webengine-path" " (default " "$(XDG_DATA_HOME)/qutebrowser/webengine")
|
||||
The location of the Chromium/QtWebEngine state directory.
|
||||
.TP 4
|
||||
.BR "whitelist-path" " (default " "$(XDG_CONFIG_HOME)/qutebrowser/whitelists/cookies")
|
||||
The location of the domain whitelist.
|
||||
|
||||
.SH EXAMPLE
|
||||
|
||||
This is an example configuration:
|
||||
.IP
|
||||
.nf
|
||||
\fC
|
||||
# This is a comment
|
||||
whitelist-path = "/home/alice/docs/cookie-whitelist"
|
||||
# You can also access environment variables:
|
||||
webengine-path = "$(HOME)/.local/qutebrowser/webengine"
|
||||
\fR
|
||||
.fi
|
||||
|
||||
.SH SEE ALSO
|
||||
\fBbisc\fR(1) for the bisc command
|
||||
|
||||
.SH AUTHORS
|
||||
Copyright © 2021 Michele Guerini Rocco.
|
||||
.TP 0
|
||||
Released under the GPL, version 3 or greater.
|
||||
This software carries no warranty of any kind.
|
Loading…
Reference in New Issue