Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
m8rge committed Jun 23, 2018
1 parent 813fff2 commit da5a62b
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
# yandex.music.app
Yandex Music web app. Electron powered

# Requirements

* https://github.com/jiahaog/nativefier

# Build

```bash
$ ./build.sh
```
3 changes: 3 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

nativefier https://music.yandex.ru --single-instance -n Yandex.Music -i ./og-image.png --inject ./renderer.js --internal-urls "(?:music|passport)\.yandex\.ru/.*"
Binary file added og-image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions renderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
'use strict';
const {globalShortcut, dialog} = require('electron').remote;
const currentWindow = require('electron').remote.getCurrentWindow();
const currentWebContents = currentWindow.webContents;

const init = () => {
if (window.location.host !== 'music.yandex.ru') {
return;
}

var ret;

ret = globalShortcut.register('MediaPlayPause', () => {
externalAPI.togglePause();
});
if (!ret) {
dialog.showErrorBox('Cant bind global shortcut', 'Cant bind MediaPlayPause. Closing tab.\nPossible second opened tab?');
currentWindow.close();
return;
}

ret = globalShortcut.register('MediaNextTrack', () => {
externalAPI.next();
});
if (!ret) {
dialog.showErrorBox('Cant bind global shortcut', 'Cant bind MediaNextTrack. Closing tab. \nPossible second opened tab?');
currentWindow.close();
return;
}

ret = globalShortcut.register('MediaPreviousTrack', () => {
externalAPI.prev();
});
if (!ret) {
dialog.showErrorBox('Cant bind global shortcut', 'Cant bind MediaPreviousTrack. Closing tab. \nPossible second opened tab?');
currentWindow.close();
}
};

currentWebContents.on('did-finish-load', init);

0 comments on commit da5a62b

Please sign in to comment.