Skip to content

Commit

Permalink
Merge pull request #53 from TanukiPenny/forward-and-back
Browse files Browse the repository at this point in the history
  • Loading branch information
JustYuuto authored Jul 29, 2024
2 parents ba46c4d + 2dd5799 commit f999fd7
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/utils/Window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,37 @@ export async function load(app: Electron.App) {
const playingObserver = new MutationObserver(() => ipcRenderer.send('update_activity', false));
playingObserver.observe(document.querySelector('.chakra-button__group > button[data-testid^="play_button_"]'), { childList: true, subtree: true });`);
ipcMain.on('update_activity', (e, currentTimeChanged) => updateActivity(app, currentTimeChanged));
runJs(`const chakraStack = document.querySelector('#dzr-app > div > div.css-efpag6 > div.chakra-stack.css-w8kdg9');
const navContainer = document.createElement('div');
navContainer.style.display = 'flex';
navContainer.style.justifyContent = 'space-around';
const backButton = document.createElement('button');
backButton.addEventListener('click', () => ipcRenderer.send('nav_back'));
backButton.textContent = '<';
backButton.style.transform = 'scale(2, 4)';
backButton.style.opacity = '30%';
const forwardButton = document.createElement('button');
forwardButton.addEventListener('click', () => ipcRenderer.send('nav_forward'));
forwardButton.textContent = '>';
forwardButton.style.transform = 'scale(2, 4)';
forwardButton.style.opacity = '30%';
navContainer.appendChild(backButton);
navContainer.appendChild(forwardButton);
chakraStack.children[0].replaceWith(navContainer);`);
ipcMain.on('nav_back', () => win.webContents.goBack());
ipcMain.on('nav_forward', () => win.webContents.goForward());
win.webContents.on('did-stop-loading', () => {
if (win.webContents.canGoBack()) {
runJs('backButton.style.opacity = \'100%\';');
} else {
runJs('backButton.style.opacity = \'30%\';');
}
if (win.webContents.canGoForward()) {
runJs('forwardButton.style.opacity = \'100%\';');
} else {
runJs('forwardButton.style.opacity = \'30%\';');
}
});
setThumbarButtons();
});
}
Expand Down

0 comments on commit f999fd7

Please sign in to comment.