Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into Ev2.2.0-Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Bas950 committed Feb 21, 2021
2 parents 96cb051 + 8da058b commit a597fb4
Show file tree
Hide file tree
Showing 293 changed files with 10,513 additions and 3,630 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/service_request.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Service request
name: Service/Presence request
about: Suggest Rich Presence support for a website
---

Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE/presence_modification.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
Name: Presence Modification
About: Pull request template for publishing changes for a presnce.
About: Pull request template for publishing changes for a presence.
---

_In order to property modify presences, please take a look at the [documentation](https://docs.premid.app/dev/presence). Take a look at the guidelines to see what is acceptable._
Expand Down
16 changes: 15 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,23 @@ updates:
interval: "weekly"
assignees:
- "TheDropX"
- "Timeraa"
commit-message:
prefix: "🔼"
prefix-development: "🔼"
labels:
- "dependencies"
open-pull-requests-limit: 15
open-pull-requests-limit: 15
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
assignees:
- "TheDropX"
- "Timeraa"
commit-message:
prefix: "🔼"
prefix-development: "🔼"
labels:
- "dependencies"
open-pull-requests-limit: 15
2 changes: 1 addition & 1 deletion .resources/README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ In this folder you can find resource images which you can use to display the sta
| <img src="pause.png" style="background-color: rgba(0,0,0,25);" height="50px"> | [pause.png](pause.png) |
| <img src="stop.png" style="background-color: rgba(0,0,0,25);" height="50px"> | [stop.png](stop.png) |
| <img src="search.png" style="background-color: rgba(0,0,0,25);" height="50px"> | [search.png](search.png) |
| <img src="question.png" style="background-color: rgba(0,0,0,25);" height="50px"> | [question.png](question.png) |
| <img src="question.png" style="background-color: rgba(0,0,0,25);" height="50px"> | [question.png](question.png) |
| <img src="live.png" style="background-color: rgba(0,0,0,25);" height="50px"> | [live.png](live.png) |
| <img src="reading.png" style="background-color: rgba(0,0,0,25);" height="50px"> | [reading.png](reading.png) |
| <img src="writing.png" style="background-color: rgba(0,0,0,25);" height="50px"> | [writing.png](writing.png) |
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,25 @@
"@babel/core": "^7.12.10",
"@babel/preset-env": "^7.12.11",
"@types/babel__core": "^7.1.12",
"@types/chrome": "^0.0.127",
"@types/chrome": "^0.0.130",
"@types/glob": "^7.1.3",
"@types/mongodb": "3.6.3",
"@types/node": "^14.14.19",
"@types/prettier": "^2.1.6",
"@types/node": "^14.14.28",
"@types/prettier": "^2.2.1",
"@types/semver": "^7.3.4",
"@typescript-eslint/eslint-plugin": "^4.11.1",
"@typescript-eslint/parser": "^4.11.1",
"@typescript-eslint/eslint-plugin": "^4.15.0",
"@typescript-eslint/parser": "^4.14.1",
"axios": "^0.21.1",
"chalk": "^4.1.0",
"eslint": "^7.17.0",
"eslint": "^7.20.0",
"execa": "^5.0.0",
"glob": "^7.1.6",
"jsonschema": "^1.4.0",
"mongodb": "^3.6.3",
"prettier": "^2.2.1",
"semver": "^7.3.4",
"source-map-support": "^0.5.19",
"terser": "^5.5.1",
"terser": "^5.6.0",
"typescript": "^3.9.7"
}
}
30 changes: 30 additions & 0 deletions websites/A/Altearn/dist/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$schema": "https://schemas.premid.app/metadata/1.3",
"author": {
"name": "fantomitechno 🦊",
"id": "563749920683720709"
},
"url": "altearn.xyz",
"description": {
"en": "Altearn is a non-profit association which aims to develop and implement solutions and events for educational, scientific or awareness purposes.",
"fr": "Altearn est une association à but non-lucratif qui vise à déveloper et mettre en place des solutions et événements dans un but pédagogique, scientifique ou de sensibilisation."
},
"service": "Altearn",
"version": "1.0.1",
"logo": "https://i.imgur.com/FXRVkUd.png",
"thumbnail": "https://i.imgur.com/dWA3LHB.png",
"color": "#888888",
"tags": [
"community",
"altearn"
],
"category": "other",
"settings": [
{
"id": "privacy",
"title": "Privacy mode",
"icon": "fad fa-user-secret",
"value": false
}
]
}
62 changes: 62 additions & 0 deletions websites/A/Altearn/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
const presence = new Presence({
clientId: "805098006625517599"
});

presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
largeImageKey: "logo"
},
browsingStamp = Math.floor(Date.now() / 1000),
privacy = await presence.getSetting("privacy");
presenceData.startTimestamp = browsingStamp;
if (privacy) {
presenceData.details = "Browsing";
} else {
if (window.location.pathname.startsWith("/articles")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Activities";
} else if (window.location.pathname.startsWith("/category/")) {
presenceData.details = "Searching an article:";
presenceData.state =
"in category " + document.title.replace(" | Altearn", "");
if (window.location.pathname.endsWith("category/ag/")) {
presenceData.details = "Viewing a page:";
presenceData.state = "General Assembly";
}
} else if (window.location.pathname.startsWith("/assemblee-generale-")) {
presenceData.details = "Viewing an General Assembly";
presenceData.state = document.title
.replace(" | Altearn", "")
.replace("Assemblée Générale - ", "");
} else if (window.location.pathname.endsWith("/notre-organisation/")) {
presenceData.details = "Viewing a page:";
presenceData.state = "Our organisation";
} else if (
window.location.pathname.startsWith("/") &&
window.location.pathname.length != 1
) {
presenceData.details = "Reading an article:";
presenceData.state = document.title.replace(" | Altearn", "");
if (window.location.pathname.includes("/author/")) {
presenceData.details = "Looking for an user:";
presenceData.state = document.title.replace(" | Altearn", "");
}
if (document.title.includes("Fiche de poste:")) {
presenceData.details = "Viewing a place as";
presenceData.state = document.title
.replace(" | Altearn", "")
.replace("Fiche de poste:", "");
}
} else if (window.location.pathname.length === 1) {
presenceData.details = "Viewing a page:";
presenceData.state = "Home";
}
}

if (presenceData.details == null) {
presence.setTrayTitle();
presence.setActivity();
} else {
presence.setActivity(presenceData);
}
});
6 changes: 6 additions & 0 deletions websites/A/Altearn/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../tsconfig.json",
"compilerOptions": {
"outDir": "./dist/"
}
}
18 changes: 12 additions & 6 deletions websites/A/Amazon Music/dist/metadata.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
{
"author": {
"name": "Bryan",
"id": "293775922757238784"
"name": "Striker",
"id": "215509157837537280"
},
"contributors": [
{
"name": "Bryan",
"id": "293775922757238784"
}
],
"service": "Amazon Music",
"description": {
"en": "Amazon Music is a music streaming platform and online music store operated by Amazon.com. Launched in public beta on September 25, 2007, in January 2008 it became the first music store to sell music without digital rights management from the four major music labels, as well as many independents.",
"zh_CN": "Amazon Music是由Amazon.com经营的音乐媒体平台和在线音乐商店。",
"zh_TW": "Amazon Music是由Amazon.com經營的音樂串流平台和在線音樂商店。"
},
"url": "music.amazon.com",
"version": "1.2.5",
"logo": "https://i.gyazo.com/16875e5712ac33890f17235d0e46f3be.png",
"thumbnail": "https://i.gyazo.com/7f39c3c0b18337d8e6f3bcd0cf962a01.png",
"version": "2.0.0",
"logo": "https://i.imgur.com/AUKbzxX.png",
"thumbnail": "https://i.imgur.com/htSGR6k.png",
"color": "#21293C",
"tags": [
"amazon-music",
Expand All @@ -22,4 +28,4 @@
],
"category": "music",
"regExp": "music[.]amazon([.][a-z]+)+[/]"
}
}
158 changes: 111 additions & 47 deletions websites/A/Amazon Music/presence.ts
Original file line number Diff line number Diff line change
@@ -1,63 +1,127 @@
var presence = new Presence({
clientId: "619041735795802112"
const presence = new Presence({
clientId: "808756700022702120"
}),
strings = presence.getStrings({
play: "presence.playback.playing",
pause: "presence.playback.paused"
});

function getTime(list: string[]): number {
var ret = 0;
for (let index = list.length - 1; index >= 0; index--) {
ret += parseInt(list[index]) * 60 ** index;
}
return ret;
}
let fullscreen: boolean,
player = false,
paused,
currentTime,
timeLeft,
timestamps;

function getTimestamps(audioDuration: string): Array<number> {
var splitAudioDuration = audioDuration.split(":").reverse();
presence.on("UpdateData", async () => {
player =
document.querySelector(
"body > div#root > music-app.hydrated > div.BAibzabUKijQgULVQbqCf > div#transport._333T0bVoft6GGOqUYjsnIA > div._3l2xsX5-KkYUgDHJDu-L0r > music-horizontal-item"
) != undefined
? true
: false;

var parsedAudioDuration = getTime(splitAudioDuration);
if (player == true) {
const exitFSButton = document.querySelector(
"div._2kGtEHAlQ5t5sY3jvz-wwl > div._1Wgs9MKFGuL58IFgKSM811 > div._2HXusrWftEtKAYukKt5IuO > music-button"
);
exitFSButton != null ? (fullscreen = true) : (fullscreen = false);
if (fullscreen == true) {
const title = document.querySelector("a.music-headline-2").textContent,
artist = document
.querySelector("a.music-primary-text")
.textContent.split(" - ")[0],
pausedIcon = document
.querySelector("music-button.hydrated:nth-child(4)")
.shadowRoot.querySelector("button > div > music-icon");
(paused = pausedIcon.attributes[1].value == "pause" ? false : true),
(currentTime = document.querySelector(
"div.sXaGQzYs9WqImj2uxDCBs > span:nth-child(1)"
).textContent);
timeLeft = document
.querySelector("div.sXaGQzYs9WqImj2uxDCBs > span:nth-child(2)")
.textContent.replace(" - ", "");

var startTime = Date.now();
var endTime = Math.floor(startTime / 1000) + parsedAudioDuration;
return [Math.floor(startTime / 1000), endTime];
}
timestamps = presence.getTimestamps(
presence.timestampFromFormat(currentTime),
(presence.timestampFromFormat(timeLeft) + presence.timestampFromFormat(currentTime))
);

presence.on("UpdateData", async () => {
var player = document.querySelector(".playbackActive");
if (player) {
var title = document.querySelector(".trackTitle span").textContent;
var artist = document.querySelector(".trackArtist span").textContent;
var durationTime = document.querySelector(
".listViewDurationContextButton .listViewDuration"
).textContent;
var timestamps = getTimestamps(durationTime.replace("-", ""));
const paused = document.querySelector(
".playbackControls span.playerIconPause"
)
? false
: true;

var data: PresenceData = {
details: title,
state: artist,
largeImageKey: "amazonmusic-logo",
smallImageKey: paused ? "pause" : "play",
smallImageText: paused ? (await strings).pause : (await strings).play,
startTimestamp: timestamps[0],
endTimestamp: timestamps[1]
};
const data: PresenceData = {
details: title,
state: artist,
smallImageKey: paused == true ? "pause" : "play",
smallImageText:
paused == true ? (await strings).pause : (await strings).play,
largeImageKey: "logo",
startTimestamp: timestamps[0],
endTimestamp: timestamps[1]
};

if (paused) {
delete data.startTimestamp;
delete data.endTimestamp;
}
if (paused) {
delete data.startTimestamp;
delete data.endTimestamp;
}

if (title !== null && artist !== null) {
presence.setActivity(data, !paused);
if (title !== null && artist !== null) {
presence.setActivity(data);
}
} else {
const title = document
.querySelector(
"body > div#root > music-app.hydrated > div.BAibzabUKijQgULVQbqCf > div#transport._333T0bVoft6GGOqUYjsnIA > div._3l2xsX5-KkYUgDHJDu-L0r > music-horizontal-item"
)
.shadowRoot.querySelector(
"div.item.parent-undefined > div.center > music-link.hydrated > a"
).textContent,
artist = document
.querySelector(
"body > div#root > music-app.hydrated > div.BAibzabUKijQgULVQbqCf > div#transport._333T0bVoft6GGOqUYjsnIA > div._3l2xsX5-KkYUgDHJDu-L0r > music-horizontal-item"
)
.shadowRoot.querySelector(
"div.item.parent-undefined > div.center > span"
)
.textContent.split("-")[0],
pausedIcon = document
.querySelector("music-button.hydrated:nth-child(4)")
.shadowRoot.querySelector("button > div > music-icon");
(paused = pausedIcon.attributes[1].value == "pause" ? false : true),
(currentTime = document
.querySelector("div.sXaGQzYs9WqImj2uxDCBs._1KQKoAP31YB14fDTsoEmwh")
.textContent.split(" - ")[0]);
(timeLeft = document
.querySelector("div.sXaGQzYs9WqImj2uxDCBs._1KQKoAP31YB14fDTsoEmwh")
.textContent.split(" - ")[1]),
(timestamps = presence.getTimestamps(
presence.timestampFromFormat(currentTime),
(presence.timestampFromFormat(timeLeft) + presence.timestampFromFormat(currentTime))
));

const data: PresenceData = {
details: title,
state: artist,
largeImageKey: "logo",
startTimestamp: timestamps[0],
smallImageKey: paused == true ? "pause" : "play",
smallImageText:
paused == true ? (await strings).pause : (await strings).play,
endTimestamp: timestamps[1]
};

if (paused) {
delete data.startTimestamp;
delete data.endTimestamp;
}

if (title !== null && artist !== null) {
presence.setActivity(data);
}
}
} else {
presence.clearActivity();
const data: PresenceData = {
details: "Browsing...",
largeImageKey: "logo"
};
presence.setActivity(data);
}
});
Loading

0 comments on commit a597fb4

Please sign in to comment.