Introduction
Introduction Statistics Contact Development Disclaimer Help
user_agent.py - dotfiles - These are my dotfiles. There are many like it, but t…
git clone git://jay.scot/dotfiles
Log
Files
Refs
README
---
user_agent.py (892B)
---
1 # qutebrowser script to set a random user-agent on launch. Add the follo…
2 # your qutebrowser config.py file:
3 #
4 # config.source('scripts/user_agent.py')
5 #
6 # You can download the most common user-agents with a script like this, …
7 # mine on cron every 3 days. :
8 #
9 # #!/bin/bash
10 #
11 # url='https://raw.githubusercontent.com/Kikobeats/top-user-agents/maste…
12 # path="$HOME/.config/qutebrowser/useragent_list.json"
13 #
14 # curl "$url" -o "$path"
15 # awk '!/Firefox/' "$path" > /tmp/1 && mv /tmp/1 "$path"
16
17 import random
18 import json
19
20 from pathlib import Path
21 from qutebrowser.api import message
22
23 home = str(config.configdir)
24 agentfile = Path("{}/useragent_list.json".format(home))
25
26 if agentfile.is_file():
27 with open(agentfile, "r") as filehandle:
28 agentList = json.load(filehandle)
29
30 agent = random.choice(tuple(agentList))
31 c.content.headers.user_agent = agent
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.