diff options
| author | Akshay Nair <phenax5@gmail.com> | 2020-12-21 18:52:51 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2020-12-21 18:52:51 +0530 |
| commit | f1cf59ce2df9204f818cfd038538a2a31a5c2262 (patch) | |
| tree | 35b0a21501615b7551514262b96e9d8113375cbc /config/qutebrowser/security.py | |
| parent | 6ff5a17adcf1ed72cd2f1c7bff606bdd3352b3bb (diff) | |
| download | nixos-config-f1cf59ce2df9204f818cfd038538a2a31a5c2262.tar.gz nixos-config-f1cf59ce2df9204f818cfd038538a2a31a5c2262.zip | |
Adds qutebrowser config
Diffstat (limited to '')
| -rw-r--r-- | config/qutebrowser/security.py | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/config/qutebrowser/security.py b/config/qutebrowser/security.py new file mode 100644 index 0000000..f503b6d --- /dev/null +++ b/config/qutebrowser/security.py @@ -0,0 +1,86 @@ +import random +from qutebrowser.config.configfiles import ConfigAPI +from qutebrowser.config.config import ConfigContainer +config = config +c = c + +def compose(*args): + return ' ;; '.join(args) + +def enable(s, ask = False): + return 'set ' + s + ' ' + ('ask' if ask else 'True') + +def disable(s): + return 'set ' + s + ' False' + + +def rand_numstr(a, b): + return str(random.randint(a, b)) + +def random_version(a, b): + return rand_numstr(a, b) + '.' + rand_numstr(0, 100) + +def random_useragent(): + chrome_version = random_version(77, 84) + # firefox_version = random_version(77, 80) + build_version = random_version(1000, 3000) + + agents = [ + 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML; like Gecko) Chromium/' + chrome_version + '.0.4044.138 Chrome/' + chrome_version + '.' + build_version + ' Safari/{webkit_version}', + 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/' + chrome_version + '.0.4147.89 Safari/{webkit_version} Hola/1.173.900', + 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/' + chrome_version + '.0.2623.112 Safari/{webkit_version}' + # 'Mozilla/5.0 (Linux x86_64; rv:78.0) Gecko/20100101 Firefox/' + firefox_version, + ] + return agents[random.randint(0, 2)] + +c.content.cookies.accept = 'no-3rdparty' +c.content.geolocation = 'ask' +c.content.headers.do_not_track = True +c.content.headers.referer = 'never' +c.content.headers.user_agent = random_useragent() +c.content.host_blocking.enabled = True +c.content.media.audio_capture = 'ask' +c.content.media.video_capture = 'ask' +c.content.ssl_strict = 'ask' +c.content.desktop_capture = 'ask' +c.content.mouse_lock = 'ask' +c.content.javascript.can_access_clipboard = True +c.content.canvas_reading = True +# c.content.fullscreen.window = True # Fullscreen fixed to window size + +# Tor +c.aliases['tor-enable'] = 'set content.proxy "socks://localhost:9050"' +c.aliases['tor-disable'] = 'config-unset content.proxy' +c.aliases['tor-change'] = 'spawn --userscript tor_identity' + +# Fingerprinting feature switches +c.aliases['clipboard-disable'] = disable('content.javascript.can_access_clipboard') +c.aliases['clipboard-enable'] = enable('content.javascript.can_access_clipboard') +c.aliases['canvas-disable'] = disable('content.canvas_reading') +c.aliases['canvas-enable'] = enable('content.canvas_reading') +c.aliases['webgl-disable'] = disable('content.webgl') +c.aliases['webgl-enable'] = enable('content.webgl') +c.aliases['location-disable'] = disable('content.geolocation') +c.aliases['location-enable'] = enable('content.geolocation', ask=True) + +# Incognito identity switch +c.aliases['change-identity'] = compose('config-source', c.aliases['tor-change']) + +def set_incognito(mode): + tor = 'enable' if mode else 'disable' + features = 'disable' if mode else 'enable' + return compose( + 'config-source', + c.aliases['tor-' + tor], + c.aliases['clipboard-' + features], + c.aliases['location-' + features], + c.aliases['canvas-' + features], + c.aliases['webgl-' + features], + ) + +c.aliases['incognito-enable'] = set_incognito(True) +c.aliases['incognito-disable'] = set_incognito(False) + + +c.aliases['ask-useragent'] = 'spawn --userscript pick_useragent' + |
