-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 26d4107
Showing
14 changed files
with
3,945 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
out |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# XM Menu Player |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP --> | ||
<meta | ||
http-equiv="Content-Security-Policy" | ||
content="default-src 'self'; script-src 'self'" | ||
/> | ||
<title></title> | ||
</head> | ||
<body> | ||
<!-- You can also require other files to run in this process --> | ||
<script src="./renderer.js"></script> | ||
</body> | ||
</html> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Modules to control application life and create native browser window | ||
const { app } = require("electron"); | ||
const path = require("path"); | ||
const { menubar } = require("menubar"); | ||
|
||
const mb = menubar({ | ||
browserWindow: { width: 450, height: 660 }, | ||
preloadWindow: true, | ||
icon: path.join(__dirname, "/MenuIcon.png"), | ||
webPreferences: { | ||
partition: "persist:xmmenuplayer", | ||
}, | ||
}); | ||
|
||
mb.app.commandLine.appendSwitch( | ||
"disable-backgrounding-occluded-windows", | ||
"true" | ||
); | ||
|
||
mb.on("ready", () => { | ||
console.log("app is ready"); | ||
|
||
win = mb.window; | ||
// win.openDevTools(); | ||
|
||
// First URL | ||
win.loadURL("https://player.siriusxm.com/now-playing"); | ||
|
||
// mb.on('after-create-window', () => { | ||
|
||
// Once dom-ready | ||
win.webContents.once("dom-ready", () => { | ||
setInterval(() => { | ||
// Artist Name | ||
const artistName = win.webContents | ||
.executeJavaScript( | ||
`document.querySelector('.sxm-player-controls .artist-name').innerText` | ||
) | ||
.then((result) => result.trim()); | ||
|
||
// Track Name | ||
const trackName = win.webContents | ||
.executeJavaScript( | ||
`document.querySelector('.sxm-player-controls .track-name').innerText` | ||
) | ||
.then((result) => result.trim()); | ||
|
||
// Player State | ||
const playerState = win.webContents | ||
.executeJavaScript( | ||
`document.querySelector('.sxm-player-controls .play-pause-btn').getAttribute('title')` | ||
) | ||
.then((result) => result.trim()) | ||
.then((state) => (state == "Play" ? "⏸︎" : "")); | ||
|
||
Promise.all([artistName, trackName, playerState]) | ||
.then(([artistName, trackName, playerState]) => { | ||
// Set Menubar Title | ||
mb.tray.setTitle(`${playerState} ${artistName} - ${trackName}`); | ||
}) | ||
.catch(() => {}); | ||
}, 1000); | ||
}); | ||
}); | ||
|
||
// Quit when all windows are closed, except on macOS. There, it's common | ||
// for applications and their menu bar to stay active until the user quits | ||
// explicitly with Cmd + Q. | ||
app.on("window-all-closed", function () { | ||
if (process.platform !== "darwin") app.quit(); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "xmmenuplayer", | ||
"productName": "XM Menu Player", | ||
"description": "Menu bar app for easily accessing the SiriusXM Player", | ||
"keywords": [], | ||
"main": "./main.js", | ||
"version": "1.0.0", | ||
"author": "rosswaycaster", | ||
"scripts": { | ||
"start": "electron-forge start", | ||
"package": "electron-forge package", | ||
"make": "electron-forge make", | ||
"publish": "electron-forge publish", | ||
"lint": "echo \"No linting configured\"" | ||
}, | ||
"dependencies": { | ||
"menubar": "*" | ||
}, | ||
"devDependencies": { | ||
"electron": "15.3.0", | ||
"@electron-forge/cli": "^6.0.0-beta.59", | ||
"@electron-forge/maker-deb": "^6.0.0-beta.59", | ||
"@electron-forge/maker-rpm": "^6.0.0-beta.59", | ||
"@electron-forge/maker-squirrel": "^6.0.0-beta.59", | ||
"@electron-forge/maker-zip": "^6.0.0-beta.59" | ||
}, | ||
"config": { | ||
"forge": { | ||
"packagerConfig": { | ||
"platform": "all", | ||
"icon": "./Icon" | ||
}, | ||
"makers": [ | ||
{ | ||
"name": "@electron-forge/maker-squirrel" | ||
}, | ||
{ | ||
"name": "@electron-forge/maker-zip", | ||
"platforms": [ | ||
"darwin" | ||
] | ||
}, | ||
{ | ||
"name": "@electron-forge/maker-deb", | ||
"config": {} | ||
}, | ||
{ | ||
"name": "@electron-forge/maker-rpm", | ||
"config": {} | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// All of the Node.js APIs are available in the preload process. | ||
// It has the same sandbox as a Chrome extension. | ||
window.addEventListener('DOMContentLoaded', () => { | ||
const replaceText = (selector, text) => { | ||
const element = document.getElementById(selector) | ||
if (element) element.innerText = text | ||
} | ||
|
||
for (const type of ['chrome', 'node', 'electron']) { | ||
replaceText(`${type}-version`, process.versions[type]) | ||
} | ||
}) |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// This file is required by the index.html file and will | ||
// be executed in the renderer process for that window. | ||
// No Node.js APIs are available in this process because | ||
// `nodeIntegration` is turned off. Use `preload.js` to | ||
// selectively enable features needed in the rendering | ||
// process. |
Oops, something went wrong.