Move UserAgent to configdata
This commit is contained in:
parent
616aad84d8
commit
8de0445661
@ -421,8 +421,52 @@ content.referer_header:
|
||||
content.user_agent:
|
||||
default: ""
|
||||
type:
|
||||
name: UserAgent
|
||||
name: String
|
||||
none_ok: true
|
||||
completions:
|
||||
# To update the following list of user agents, run the script 'ua_fetch.py'
|
||||
# Vim-protip: Place your cursor below this comment and run
|
||||
# :r!python scripts/dev/ua_fetch.py
|
||||
- - "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:53.0) Gecko/20100101
|
||||
Firefox/53.0"
|
||||
- Firefox 53.0 Win8.1
|
||||
- - "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:53.0) Gecko/20100101
|
||||
Firefox/53.0"
|
||||
- Firefox 53.0 Linux
|
||||
- - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:53.0) Gecko/20100101
|
||||
Firefox/53.0"
|
||||
- Firefox 53.0 MacOSX
|
||||
|
||||
- - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4
|
||||
(KHTML, like Gecko) Version/10.1.1 Safari/603.2.4"
|
||||
- Safari Generic MacOSX
|
||||
- - "Mozilla/5.0 (iPad; CPU OS 10_3_1 like Mac OS X) AppleWebKit/603.1.30
|
||||
(KHTML, like Gecko) Version/10.0 Mobile/14E304 Safari/602.1"
|
||||
- Mobile Safari 10.0 iOS
|
||||
|
||||
- - "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
|
||||
like Gecko) Chrome/58.0.3029.110 Safari/537.36"
|
||||
- Chrome Generic Win10
|
||||
- - "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/537.36
|
||||
(KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"
|
||||
- Chrome Generic MacOSX
|
||||
- - "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like
|
||||
Gecko) Chrome/58.0.3029.110 Safari/537.36"
|
||||
- Chrome Generic Linux
|
||||
|
||||
- - "Mozilla/5.0 (compatible; Googlebot/2.1;
|
||||
+http://www.google.com/bot.html"
|
||||
- Google Bot
|
||||
- - "Wget/1.16.1 (linux-gnu)"
|
||||
- wget 1.16.1
|
||||
- - "curl/7.40.0"
|
||||
- curl 7.40.0
|
||||
- - "Mozilla/5.0 (Linux; U; Android 7.1.2) AppleWebKit/534.30 (KHTML, like
|
||||
Gecko) Version/4.0 Mobile Safari/534.30"
|
||||
- Mobile Generic Android
|
||||
- - "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko"
|
||||
- IE 11.0 for Desktop Win7 64-bit
|
||||
|
||||
desc: User agent to send. Empty to send the default.
|
||||
|
||||
content.proxy:
|
||||
|
@ -1301,75 +1301,6 @@ class NewTabPosition(BaseType):
|
||||
('last', "At the end."))
|
||||
|
||||
|
||||
class UserAgent(BaseType):
|
||||
|
||||
"""The user agent to use."""
|
||||
|
||||
# FIXME:conf refactor
|
||||
|
||||
def validate(self, value):
|
||||
self._basic_validation(value)
|
||||
try:
|
||||
value.encode('ascii')
|
||||
except UnicodeEncodeError as e:
|
||||
msg = "User-Agent contains non-ascii characters: {}".format(e)
|
||||
raise configexc.ValidationError(value, msg)
|
||||
|
||||
# To update the following list of user agents, run the script 'ua_fetch.py'
|
||||
# Vim-protip: Place your cursor below this comment and run
|
||||
# :r!python scripts/dev/ua_fetch.py
|
||||
def complete(self):
|
||||
"""Complete a list of common user agents."""
|
||||
out = [
|
||||
('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 '
|
||||
'Firefox/47.0',
|
||||
"Firefox Generic Win7"),
|
||||
('Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:47.0) '
|
||||
'Gecko/20100101 Firefox/47.0',
|
||||
"Firefox Generic MacOSX"),
|
||||
('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 '
|
||||
'Firefox/47.0',
|
||||
"Firefox Generic Linux"),
|
||||
|
||||
('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) '
|
||||
'AppleWebKit/601.7.7 (KHTML, like Gecko) Version/9.1.2 '
|
||||
'Safari/601.7.7',
|
||||
"Safari Generic MacOSX"),
|
||||
('Mozilla/5.0 (iPad; CPU OS 9_3_2 like Mac OS X) '
|
||||
'AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 '
|
||||
'Mobile/13F69 Safari/601.1',
|
||||
"Mobile Safari 9.0 iOS"),
|
||||
|
||||
('Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 '
|
||||
'(KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36',
|
||||
"Chrome Generic Win10"),
|
||||
('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) '
|
||||
'AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 '
|
||||
'Safari/537.36',
|
||||
"Chrome Generic MacOSX"),
|
||||
('Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 '
|
||||
'(KHTML, like Gecko) Chrome/51.0.2704.106 Safari/537.36',
|
||||
"Chrome Generic Linux"),
|
||||
|
||||
('Mozilla/5.0 (compatible; Googlebot/2.1; '
|
||||
'+http://www.google.com/bot.html',
|
||||
"Google Bot"),
|
||||
('Wget/1.16.1 (linux-gnu)',
|
||||
"wget 1.16.1"),
|
||||
('curl/7.40.0',
|
||||
"curl 7.40.0"),
|
||||
|
||||
('Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like '
|
||||
'Gecko',
|
||||
"IE 11.0 for Desktop Win7 64-bit"),
|
||||
|
||||
('Mozilla/5.0 (Linux; U; Android 7.1.2) AppleWebKit/534.30 '
|
||||
'(KHTML, like Gecko) Version/4.0 Mobile Safari/534.30',
|
||||
"Mobile Generic Android")
|
||||
]
|
||||
return out
|
||||
|
||||
|
||||
class TimestampTemplate(BaseType):
|
||||
|
||||
"""An strftime-like template for timestamps.
|
||||
|
@ -24,7 +24,7 @@
|
||||
"""Fetch list of popular user-agents.
|
||||
|
||||
The script is based on a gist posted by github.com/averrin, the output of this
|
||||
script is formatted to be pasted into configtypes.py.
|
||||
script is formatted to be pasted into configdata.yml
|
||||
"""
|
||||
|
||||
import requests
|
||||
@ -90,7 +90,10 @@ def add_diversity(table):
|
||||
"curl 7.40.0"),
|
||||
('Mozilla/5.0 (Linux; U; Android 7.1.2) AppleWebKit/534.30 '
|
||||
'(KHTML, like Gecko) Version/4.0 Mobile Safari/534.30',
|
||||
"Mobile Generic Android")
|
||||
"Mobile Generic Android"),
|
||||
('Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like '
|
||||
'Gecko',
|
||||
"IE 11.0 for Desktop Win7 64-bit"),
|
||||
]
|
||||
return table
|
||||
|
||||
@ -106,24 +109,14 @@ def main():
|
||||
filtered = filter_list(fetched, lut)
|
||||
filtered = add_diversity(filtered)
|
||||
|
||||
tab = " "
|
||||
print(tab + "def complete(self):")
|
||||
print((2 * tab) + "\"\"\"Complete a list of common user agents.\"\"\"")
|
||||
print((2 * tab) + "out = [")
|
||||
|
||||
tab = " "
|
||||
for browser in ["Firefox", "Safari", "Chrome", "Obscure"]:
|
||||
for it in filtered[browser]:
|
||||
print("{}(\'{}\',\n{} \"{}\"),".format(3 * tab, it[0],
|
||||
3 * tab, it[1]))
|
||||
print('{}- - "{}"'.format(3 * tab, it[0]))
|
||||
desc = it[1].replace('\xa0', ' ').replace(' ', ' ')
|
||||
print("{}- {}".format(4 * tab, desc))
|
||||
print("")
|
||||
|
||||
print("""\
|
||||
('Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like '
|
||||
'Gecko',
|
||||
"IE 11.0 for Desktop Win7 64-bit")""")
|
||||
|
||||
print("{}]\n{}return out\n".format(2 * tab, 2 * tab))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
Loading…
Reference in New Issue
Block a user