Last active
September 18, 2018 00:33
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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