Skip to content

Instantly share code, notes, and snippets.

@szarroug3
Last active September 18, 2018 00:33
Show Gist options
  • Save szarroug3/0b542317eacfe2067813967e93c6e7e3 to your computer and use it in GitHub Desktop.
Save szarroug3/0b542317eacfe2067813967e93c6e7e3 to your computer and use it in GitHub Desktop.
Adds window_group_move.css to vivaldi and updates browser.html to use it; meant to be used with https://gist.github.com/szarroug3/2aaf6c129f4da7d288f00d6bb333c21c
import os
from shutil import copyfile
def copy_file(dest):
copyfile('window_group_move.css', dest)
def edit_browser_html(filename):
with open(filename) as f:
browser_html = f.readlines()
head = None
for i, l in enumerate(browser_html):
if '</head>' in l:
head = i
if 'window_group_move' in l:
return
if head:
browser_html.insert(head, ' <link rel="stylesheet" href="style/window_group_move.css" />\n')
else:
raise ValueError('Could not find </head> in browser.html.')
with open(filename, 'w') as f:
f.write(''.join(browser_html))
if __name__ == '__main__':
app_folder = os.path.join(os.path.expanduser('~'), 'AppData', 'Local', 'Vivaldi', 'Application')
vivaldi_folder = os.path.join(app_folder, os.listdir(app_folder)[0], 'resources', 'vivaldi')
window_group_move_dest = os.path.join(vivaldi_folder, 'style', 'window_group_move.css')
copy_file(window_group_move_dest)
browser_file = os.path.join(vivaldi_folder, 'browser.html')
edit_browser_html(browser_file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment