Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Microsoft Store as both a platform and client #28

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ It can also be sideloaded from the [releases](https://github.com/UWPCommunity/UW

| | | | | | | |
| - | - | - | - | - | - | - |
| ![Legere logo](assets/icons/clients/Legere.png) | ![Reddplannet logo](assets/icons/platforms/Reddit.png) | ![myTube logo](assets/icons/clients/myTube.png) | ![Mixplay for Mixer logo](assets/icons/platforms/Mixer.png) | ![Quarrel logo](assets/icons/clients/Quarrel.png) | ![Strix Music logo](assets/icons/clients/Strix Music.png) | ![Xpo Music logo](assets/icons/clients/Xpo%20Music.png) |
| <font size="+1">[Legere](https://www.microsoft.com/en-us/p/legere-for-reddit/9phjrvcskvjz)</font> | <font size="+0.7">[Reddplanet](https://www.microsoft.com/en-us/p/reddplanet/9nblggh4s44m)</font> | <font size="+1">[myTube](https://www.microsoft.com/en-us/p/mytube/9wzdncrcwf3l)</font> | <font size="+1">[Mixplay](https://www.microsoft.com/en-us/p/mixplay-for-mixer/9pn94d9bdfzm)</font> | <font size="+1">[Quarrel](https://www.microsoft.com/en-us/p/quarrel/9nbrwj777c8r)</a> | <font size="+1">[Spotimo](https://www.microsoft.com/en-us/p/spotimo-beta/9p75w183m6qr)</font> | <font size="+1">[Xpo Music](https://www.microsoft.com/en-us/p/xpotify-a-modern-spotify-experience-for-windows-10/9n1n68mc7fxr)</font> |
| ![Legere logo](assets/icons/clients/Legere.png) | ![Reddplannet logo](assets/icons/platforms/Reddit.png) | ![myTube logo](assets/icons/clients/myTube.png) | ![Mixplay for Mixer logo](assets/icons/platforms/Mixer.png) | ![Quarrel logo](assets/icons/clients/Quarrel.png) | ![Strix Music logo](assets/icons/clients/Strix Music.png) | ![Xpo Music logo](assets/icons/clients/Xpo%20Music.png) | ![MS Store logo](assets/icons/clients/MicrosoftStore.png) |
| <font size="+1">[Legere](https://www.microsoft.com/en-us/p/legere-for-reddit/9phjrvcskvjz)</font> | <font size="+0.7">[Reddplanet](https://www.microsoft.com/en-us/p/reddplanet/9nblggh4s44m)</font> | <font size="+1">[myTube](https://www.microsoft.com/en-us/p/mytube/9wzdncrcwf3l)</font> | <font size="+1">[Mixplay](https://www.microsoft.com/en-us/p/mixplay-for-mixer/9pn94d9bdfzm)</font> | <font size="+1">[Quarrel](https://www.microsoft.com/en-us/p/quarrel/9nbrwj777c8r)</a> | <font size="+1">[Spotimo](https://www.microsoft.com/en-us/p/spotimo-beta/9p75w183m6qr)</font> | <font size="+1">[Xpo Music](https://www.microsoft.com/en-us/p/xpotify-a-modern-spotify-experience-for-windows-10/9n1n68mc7fxr)</font> | <font size="+1">[Microsoft Store](https://www.microsoft.com/en-us/store/apps/windows)</font> |


---

Expand Down
Binary file added assets/icons/clients/Windows Store.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/icons/platforms/Microsoft Store.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logos/clients/Windows Store.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/logos/platforms/MicrosoftStore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 14 additions & 6 deletions core/helpers/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const defaultSettings = {
prefferedApp: "Strix Music",
isEnabled: true,
closeOnSwitch: false
},
"Microsoft Store": {
prefferedApp: "Windows Store",
isEnabled: true,
closeOnSwitch: true
}
}
};
Expand All @@ -45,17 +50,20 @@ export function getSettings(cb) {
chrome.storage.local.get(["settings"], result => {
if (result.settings !== undefined) {
// Check for new platforms that aren't present in stored settings
for (let name of Object.keys(defaultSettings.platforms)) {
if (result.settings.platforms[name] === undefined) {
result.settings.platforms[name] == defaultSettings.platforms[name];
for (let key of Object.keys(defaultSettings.platforms)) {
if (result.settings.platforms[key] === undefined) {

result.settings.platforms =
{ ...result.settings.platforms, [key]: defaultSettings.platforms[key] }

}
}

// Check for client names that have changed but old values are still stored in settings
for (let name of Object.keys(result.settings.platforms)) {
if (libs.platforms[name].clients[result.settings.platforms[name].prefferedApp] == undefined) {
for (let key of Object.keys(result.settings.platforms)) {
if (libs.platforms[key].clients[result.settings.platforms[key].prefferedApp] == undefined) {
// Restore to default app when the name of the preffered app changes
result.settings.platforms[name].prefferedApp = defaultSettings.platforms[name].prefferedApp;
result.settings.platforms[key].prefferedApp = defaultSettings.platforms[key].prefferedApp;
}
}

Expand Down
11 changes: 11 additions & 0 deletions core/lib/mircosoftstore/master.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import MSSParser from './parsing.js';

import MSStore from './store.js'

export default {
name: "Microsoft Store",
baseUrlMatch: MSSParser.isStore,
clients: {
MSStore
}
};
47 changes: 47 additions & 0 deletions core/lib/mircosoftstore/parsing.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
function isStore(url) {
if (typeof url == 'string') {
let match = url.match(/^https?:\/\/(?:www.)?(microsoft\.[a-z]{0,4})?((\/[a-z,\-]*\/p\/)|(\/store\/[a-z,\-]*\/))/);
return match != null;
} else console.error('Incorrect data recieved while checking domain');
}
function isHomepage(url) {
if (typeof url == 'string') {
let match = url.match(/^(?:^http.*microsoft\.[a-z]{0,4})\/(.+)\/(.+)/);
// If it matches anything after "microsoft.com/{lang}/", it isn't the homepage
return (!match || match[1]) ? false : true;
} else console.error('Incorrect data recieved while checking homepage');
}
function isApps(url) {
if (typeof url == 'string') {
let match = url.match(/^.*(?:apps)/);
return match != null;
} else console.error('Incorrect data recieved while checking Apps');
}
function isMoviesAndTv(url) {
if (typeof url == 'string') {
let match = url.match(/^.*(?:movies-and-tv)/);
return match != null;
} else console.error('Incorrect data recieved while checking Movies & TV');
}

function hasApp(url) {
if (typeof url == 'string') {
let match = url.match(/^.*(?:\/store\/apps\/)([a-zA-Z0-9-_]{12})/);
return (match && match[1]) ? match[1] : null;
} else console.error('Incorrect data recieved while checking for app');
}
function hasMovie(url) {
if (typeof url == 'string') {
let match = url.match(/^.*(?:p\/)(.+\/)([a-zA-Z0-9-_]{12})/);
return (match && match[1]) ? match[1] : null;
} else console.error('Incorrect data recieved while checking for movie');
}

export default {
isStore: isStore,
isHomepage: isHomepage,
isApps: isApps,
isMoviesAndTv: isMoviesAndTv,
hasApp: hasApp,
hasMovie: hasMovie,
};
22 changes: 22 additions & 0 deletions core/lib/mircosoftstore/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import MSSParser from './parsing.js';

export default {
config: {
color: "#0078D4",
appProtocol: "ms-windows-store"
},
name: "Windows Store",
parseUrl: function(url) {
if (MSSParser.isApps(url)) {
return "ms-windows-store://navigatetopage/?Id=Apps";
}
else if (MSSParser.hasApp(url) !== null) {
console.info('App detected.');
return `ms-windows-store://pdp/?ProductId=${MSSParser.hasApp(url)}`;
}

if (MSSParser.isHomepage(url)) {
return "ms-windows-store:";
}
}
}
4 changes: 3 additions & 1 deletion core/libs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import Reddit from './lib/reddit/master.js';
import Spotify from './lib/spotify/master.js';
import Discord from './lib/discord/master.js';
import Mixer from './lib/mixer/master.js';
import MicrosoftStore from './lib/mircosoftstore/master.js';

const platforms = {
YouTube,
Reddit,
Spotify,
Discord,
Mixer
Mixer,
"Microsoft Store": MicrosoftStore
};

for (const [platform, platformData] of Object.entries(platforms)) {
Expand Down
12 changes: 6 additions & 6 deletions user-interface/dist/bundle.js

Large diffs are not rendered by default.