Skip to content

Commit

Permalink
fix packager for mac + fix skip advert
Browse files Browse the repository at this point in the history
  • Loading branch information
dedpnd committed Sep 16, 2019
1 parent 8e2eb9e commit b68280a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 28 deletions.
21 changes: 17 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const fs = require('mz/fs');
const {
app,
BrowserWindow,
session
} = require('electron');
const store = require('./modules/store/store');
const ctxMenu = require('./modules/menu/ctxMenu');
Expand Down Expand Up @@ -111,10 +112,22 @@ app.on("ready", () => {
win.show();
})

// Skip advertising
skipAdvert.init();
// Notification for next sing
notifiNextSing.init(win);
let sendNotifi = notifiNextSing.init(win);

session.defaultSession.webRequest.onBeforeRequest(['*'], (details, callback) => {
// Skip advertising
if (/awaps.yandex.net/.test(details.url) || /vh-bsvideo-converted/.test(details.url) || /get-video-an/.test(details.url)) {
return {
cancel: true
}
}
// Notification for next sing
if (/start\?__t/.test(details.url)) {
setTimeout(sendNotifi, 1000)
}

callback(details);
})
})

app.on('before-quit', () => {
Expand Down
11 changes: 2 additions & 9 deletions modules/notifiNextSing.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
const {
session
} = require('electron');
const notification = require('./notification/notification')

const getTrack = `
Expand Down Expand Up @@ -42,12 +39,8 @@ const getImg = `
`;

exports.init = (win) => {
session.defaultSession.webRequest.onBeforeRequest(['*'], (details, callback) => {
if (/start\?__t/.test(details.url)) {
setTimeout(sendNotifi, 1000)
}
callback(details);
})

return sendNotifi

function sendNotifi() {
Promise.all([getInfoFromDOM(getTrack), getInfoFromDOM(getArtist), getInfoFromDOM(getImg)]).then((v) => {
Expand Down
14 changes: 0 additions & 14 deletions modules/skipAdvert.js

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build:all": "npm run build:win && npm run build:linux && npm run build:mac",
"build:win": "electron-packager . --platform=win32 --arch=all --icon=media/icon/yaradio_64x64.ico --name=yaMusic --executableName=yaMusic --out=distr/win --overwrite=true --ignore=distr",
"build:linux": "electron-packager . --platform=linux --arch=all --icon=media/icon/yaradio_64x64.ico --name=yaMusic --executableName=yaMusic --out=distr/linux --overwrite=true --ignore=distr",
"build:mac": "electron-packager . --platform=darwin --arch=all --icon=media/icon/yaradio_64x64.icns --name=yaMusic --executableName=yaMusic --out=distr/mac --overwrite=true --appBundleId=yaMusic --appCategoryType=public.app-category.music --ignore=distr",
"build:mac": "electron-packager . --platform=darwin --arch=all --icon=media/icon/yaradio_64x64.icns --name=yaMusic --executableName=yaMusic --out=distr/mac --overwrite=true --app-bundle-id=yaMusic --app-category-type=public.app-category.music --ignore=distr",
"gen:changelog": "github_changelog_generator -u dedpnd -p yaradio-yamusic"
},
"repository": {
Expand Down

0 comments on commit b68280a

Please sign in to comment.