diff --git a/app/filter.py b/app/filter.py index 1fd8c1b..3c21bf8 100644 --- a/app/filter.py +++ b/app/filter.py @@ -6,18 +6,13 @@ from urllib.parse import parse_qs class Filter: def __init__(self, mobile=False, config=None): - self.mobile = False - self.dark_mode = False - self.nojs = False - self.near_city = None - if config is None: config = {} - near_city = config['near'] if 'near' in config else None - dark_mode = config['dark_mode'] if 'dark_mode' in config else False - nojs = config['nojs'] if 'nojs' in config else False - mobile = mobile + self.near_city = config['near'] if 'near' in config else None + self.dark_mode = config['dark_mode'] if 'dark_mode' in config else False + self.nojs = config['nojs'] if 'nojs' in config else False + self.mobile = mobile def reskin(self, page): # Aesthetic only re-skinning diff --git a/app/routes.py b/app/routes.py index ac82867..39e4089 100644 --- a/app/routes.py +++ b/app/routes.py @@ -11,12 +11,8 @@ import urllib.parse as urlparse app.config['APP_ROOT'] = os.getenv('APP_ROOT', os.path.dirname(os.path.abspath(__file__))) app.config['STATIC_FOLDER'] = os.getenv('STATIC_FOLDER', os.path.join(app.config['APP_ROOT'], 'static')) -# Get Mozilla Firefox rhyme (important) and form a new user agent -mozilla = rhyme.get_rhyme('Mo') + 'zilla' -firefox = rhyme.get_rhyme('Fire') + 'fox' - -MOBILE_UA = mozilla + '/5.0 (Android 4.20; Mobile; rv:54.0) Gecko/54.0 ' + firefox + '/59.0' -DESKTOP_UA = mozilla + '/5.0 (Windows NT 6.1; Win64; x64; rv:59.0) Gecko/20100101 Mobile ' + firefox + '/59.0' +MOBILE_UA = '{}/5.0 (Android 0; Mobile; rv:54.0) Gecko/54.0 {}/59.0' +DESKTOP_UA = '{}/5.0 (X11; {} x86_64; rv:75.0) Gecko/20100101 {}/75.0' # Base search url SEARCH_URL = 'https://www.google.com/search?gbv=1&q=' @@ -25,7 +21,16 @@ user_config = json.load(open(app.config['STATIC_FOLDER'] + '/config.json')) def get_ua(user_agent): - return MOBILE_UA if ('Android' in user_agent or 'iPhone' in user_agent) else DESKTOP_UA + is_mobile = 'Android' in user_agent or 'iPhone' in user_agent + + mozilla = rhyme.get_rhyme('Mo') + rhyme.get_rhyme('zilla') + firefox = rhyme.get_rhyme('Fire') + rhyme.get_rhyme('fox') + linux = rhyme.get_rhyme('Lin') + 'ux' + + if is_mobile: + return MOBILE_UA.format(mozilla, firefox) + else: + return DESKTOP_UA.format(mozilla, linux, firefox) def send_request(curl_url, ua): @@ -47,7 +52,7 @@ def send_request(curl_url, ua): @app.route('/', methods=['GET']) def index(): bg = '#000' if 'dark' in user_config and user_config['dark'] else '#fff' - return render_template('index.html', bg=bg) + return render_template('index.html', bg=bg, ua=get_ua(request.headers.get('User-Agent'))) @app.route('/search', methods=['GET']) diff --git a/app/static/css/main.css b/app/static/css/main.css index eeb1fc3..f019a15 100644 --- a/app/static/css/main.css +++ b/app/static/css/main.css @@ -63,7 +63,12 @@ body { padding: 5px; } +button::-moz-focus-inner { + border: 0; +} + .collapsible { + outline: 0; background-color: rgba(0,0,0,0); color: #685e79; cursor: pointer; @@ -106,4 +111,10 @@ body { .open { padding-bottom: 20px; +} + +.ua-span { + color: white; + -webkit-box-decoration-break: clone; + box-decoration-break: clone; } \ No newline at end of file diff --git a/app/templates/index.html b/app/templates/index.html index a03cf77..0210c4f 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -33,20 +33,25 @@