Skip to content

Commit

Permalink
improve titlebar selectors + syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dragonwocky committed Jul 2, 2020
1 parent 8dfb764 commit ded4323
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
20 changes: 10 additions & 10 deletions customiser.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,22 @@
f' ...linking to {os.path.join(".", "resources", "user.css")}')
with open(os.path.join(__dirname__, 'resources', 'preload.js'), 'r', encoding='UTF-8') as insert:
append.write(insert.read().replace(
'☃☃☃assets☃☃☃', os.path.join(enhancer_folder, 'resources').replace('\\', '/'))
'☃☃☃assets☃☃☃', os.path.join(enhancer_folder, 'resources').replace('\\', '/')))
else:
print(
f' * {os.path.join(filepath, "app","renderer","preload.js")} was not found: step skipped.')

if os.path.isfile(os.path.join(filepath, "app", "main", "createWindow.js")):
with open(os.path.join(filepath, "app", "main", "createWindow.js"), 'r', encoding='UTF-8') as content:
content=content.read()
content = content.read()
print(
f' ...making window frameless @ {os.path.join(filepath, "app", "main", "createWindow.js")}')
if '{ frame: false, show: false' not in content:
content=content.replace(
content = content.replace(
'{ show: false', '{ frame: false, show: false')
print(
f' ...adding "open hidden" capabilities to {os.path.join(filepath, "app", "main", "createWindow.js")}')
content=re.sub('\\s*\\/\\* === INJECTION START === \\*\\/.*?\\/\\* === INJECTION END === \\*\\/\\s*',
content = re.sub('\\s*\\/\\* === INJECTION START === \\*\\/.*?\\/\\* === INJECTION END === \\*\\/\\s*',
'window.show()', content, flags=re.DOTALL).replace('window.show()', """
/* === INJECTION START === */
const path = require('path'),
Expand All @@ -158,10 +158,10 @@
with open(os.path.join(filepath, "app", "renderer", "index.js"), 'r', encoding='UTF-8') as content:
print(
f' ...adjusting drag area for frameless window in {os.path.join(filepath, "app", "renderer", "index.js")}')
content=content.read()
loc=content.rfind('dragRegionStyle')
content=content[:loc] + content[loc:]
.replace('top: 0', 'top: 1', 1)
content = content.read()
loc = content.rfind('dragRegionStyle')
content = content[:loc] + content[loc:] \
.replace('top: 0', 'top: 1', 1) \
.replace('height: 34', 'height: 10', 1)
with open(os.path.join(filepath, "app", "renderer", "index.js"), 'w', encoding='UTF-8') as write:
write.write(content)
Expand All @@ -175,11 +175,11 @@
f' ...adding tray support (inc. context menu with settings) to {os.path.join(filepath, "app", "main", "main.js")}')
print(
f' ...adding window toggle hotkey to {os.path.join(filepath, "app", "main", "main.js")}')
content=content.read()
content = content.read()
with open(os.path.join(filepath, "app", "main", "main.js"), 'w', encoding='UTF-8') as write:
if '/* === INJECTION MARKER === */' in content:
print(' * tray.js already added. replacing it.')
original=[]
original = []
for line in content.splitlines():
if '/* === INJECTION MARKER === */' in line:
break
Expand Down
4 changes: 3 additions & 1 deletion resources/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ require('electron').remote.getGlobal('setTimeout')(() => {
.appendChild(buttons);
document
.querySelector('.notion-history-back-button')
.parentElement.nextSibling.classList.add('notion-topbar-breadcrumb');
.parentElement.nextElementSibling.classList.add(
'notion-topbar-breadcrumb'
);
document
.querySelector('.notion-topbar-share-menu')
.parentElement.classList.add('notion-topbar-actions');
Expand Down

0 comments on commit ded4323

Please sign in to comment.