forked from PreMiD/Presences
-
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.
Merge remote-tracking branch 'upstream/master' into Ev2.2.0-Updates
- Loading branch information
Showing
293 changed files
with
10,513 additions
and
3,630 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
name: Service request | ||
name: Service/Presence request | ||
about: Suggest Rich Presence support for a website | ||
--- | ||
|
||
|
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
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
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
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
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,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 | ||
} | ||
] | ||
} |
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,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); | ||
} | ||
}); |
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 @@ | ||
{ | ||
"extends": "../../../tsconfig.json", | ||
"compilerOptions": { | ||
"outDir": "./dist/" | ||
} | ||
} |
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
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 |
---|---|---|
@@ -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); | ||
} | ||
}); |
Oops, something went wrong.