Skip to content

Commit

Permalink
♻️ Refactoring
Browse files Browse the repository at this point in the history
Signed-off-by: SeMiD <contact@premid.app>
  • Loading branch information
SeMiD committed Feb 22, 2021
1 parent 8216119 commit 58f316b
Show file tree
Hide file tree
Showing 41 changed files with 915 additions and 642 deletions.
2 changes: 1 addition & 1 deletion websites/A/Agar.io/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"en": "The smash hit game! Control your cell and eat other players to grow larger! Play with millions of players around the world and try to become the biggest cell of all!"
},
"service": "Agar.io",
"version": "1.2.0",
"version": "1.2.1",
"logo": "https://i.imgur.com/x2QZCXF.png",
"thumbnail": "https://i.imgur.com/R1Ytqci.png",
"color": "#ED1C24",
Expand Down
17 changes: 10 additions & 7 deletions websites/A/Agar.io/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ let gameStartTimestamp: number = null,

presence.on("UpdateData", async () => {
const data: PresenceData = {
largeImageKey: "agar"
},
buttons = await presence.getSetting("buttons");
largeImageKey: "agar"
},
buttons = await presence.getSetting("buttons");

if (agarData) {
if (agarData.connecting) {
Expand Down Expand Up @@ -60,10 +60,13 @@ presence.on("UpdateData", async () => {

if (buttons) {
const code = document.querySelector(".partymode-info > #code");
if (code) data.buttons = [{
label: 'Join Party',
url: document.URL
}];
if (code)
data.buttons = [
{
label: "Join Party",
url: document.URL
}
];
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions websites/A/Amazon Music/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"zh_TW": "Amazon Music是由Amazon.com經營的音樂串流平台和在線音樂商店。"
},
"url": "music.amazon.com",
"version": "2.0.0",
"version": "2.0.1",
"logo": "https://i.imgur.com/AUKbzxX.png",
"thumbnail": "https://i.imgur.com/htSGR6k.png",
"color": "#21293C",
Expand All @@ -28,4 +28,4 @@
],
"category": "music",
"regExp": "music[.]amazon([.][a-z]+)+[/]"
}
}
6 changes: 4 additions & 2 deletions websites/A/Amazon Music/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ presence.on("UpdateData", async () => {

timestamps = presence.getTimestamps(
presence.timestampFromFormat(currentTime),
(presence.timestampFromFormat(timeLeft) + presence.timestampFromFormat(currentTime))
presence.timestampFromFormat(timeLeft) +
presence.timestampFromFormat(currentTime)
);

const data: PresenceData = {
Expand Down Expand Up @@ -94,7 +95,8 @@ presence.on("UpdateData", async () => {
.textContent.split(" - ")[1]),
(timestamps = presence.getTimestamps(
presence.timestampFromFormat(currentTime),
(presence.timestampFromFormat(timeLeft) + presence.timestampFromFormat(currentTime))
presence.timestampFromFormat(timeLeft) +
presence.timestampFromFormat(currentTime)
));

const data: PresenceData = {
Expand Down
2 changes: 1 addition & 1 deletion websites/B/Bonk.io/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"en": "A multiplayer browser game where the objective is to knock all of the opponents off the edge of the screen and be the last man standing."
},
"service": "Bonk.io",
"version": "1.1.0",
"version": "1.1.1",
"logo": "https://i.imgur.com/rGFRJec.png",
"thumbnail": "https://i.imgur.com/i67aXvn.png",
"color": "#151f29",
Expand Down
20 changes: 10 additions & 10 deletions websites/B/Bonk.io/iframe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ let lastGameMode: string = null;
// Add event listeners to buttons to set game mode
document
.querySelector("#quickPlayWindow_ClassicButton")
.addEventListener("click", () => lastGameMode = "Classic");
.addEventListener("click", () => (lastGameMode = "Classic"));
document
.querySelector("#quickPlayWindow_ArrowsButton")
.addEventListener("click", () => lastGameMode = "Arrows");
.addEventListener("click", () => (lastGameMode = "Arrows"));
document
.querySelector("#quickPlayWindow_GrappleButton")
.addEventListener("click", () => lastGameMode = "Grapple");
.addEventListener("click", () => (lastGameMode = "Grapple"));

document.querySelector("#roomlistjoinbutton").addEventListener("click", () => {
const selectedMode = document.querySelector("tr.SELECTED > td:nth-child(3)");
Expand All @@ -53,15 +53,15 @@ document.querySelector("#roomlistjoinbutton").addEventListener("click", () => {

iframe.on("UpdateData", async () => {
const element = document.querySelector(selector),
lobbyGameMode = document.querySelector("#newbonklobby_modetext")?.textContent,
state = document.querySelector("#pretty_top_name").textContent +
lobbyGameMode = document.querySelector("#newbonklobby_modetext")
?.textContent,
state =
document.querySelector("#pretty_top_name").textContent +
" - " +
document.querySelector("#pretty_top_level").textContent,
playerCount = document.querySelectorAll(".newbonklobby_playerentry")
.length;
playerCount = document.querySelectorAll(".newbonklobby_playerentry").length;

if (element?.id === "newbonklobby") lastGameMode = lobbyGameMode;

if (element?.id === "newbonklobby")
lastGameMode = lobbyGameMode;

iframe.send({ lastGameMode, id: element?.id, state, playerCount });
});
12 changes: 6 additions & 6 deletions websites/B/Bonk.io/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const presence = new Presence({
};

interface IFrameData {
lastGameMode?: string,
lastGameMode?: string;
id?: string;
state: string;
playerCount: number;
Expand All @@ -19,8 +19,8 @@ let gameStartTimestamp: number = null,

presence.on("UpdateData", async () => {
const data: PresenceData = {
largeImageKey: "bonk"
};
largeImageKey: "bonk"
};

if (ifd?.id) {
data.state = ifd.state;
Expand Down Expand Up @@ -51,9 +51,9 @@ presence.on("UpdateData", async () => {
data.details = "Viewing Room List";
break;
case "newbonklobby":
data.details = `In a lobby - ${ifd.lastGameMode} (${ifd.playerCount} player${
ifd.playerCount === 1 ? "" : "s"
})`;
data.details = `In a lobby - ${ifd.lastGameMode} (${
ifd.playerCount
} player${ifd.playerCount === 1 ? "" : "s"})`;
data.smallImageKey = modePair[ifd.lastGameMode] || "classic2";
data.smallImageText = ifd.lastGameMode;
break;
Expand Down
2 changes: 1 addition & 1 deletion websites/C/CatchPlay/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"en": "CatchPlay is a Taiwanese multimedia company founded in 2007, whose businesses include OTT VOD streaming service operation, linear television channel operation (CatchPlay Movie Channel) and theatrical film distribution."
},
"service": "CatchPlay",
"version": "1.0.2",
"version": "1.0.3",
"logo": "https://i.imgur.com/hAt97QK.png",
"thumbnail": "https://i.imgur.com/vaaItvT.png",
"color": "#F26F21",
Expand Down
17 changes: 10 additions & 7 deletions websites/C/CatchPlay/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,19 @@ function getTimestamps(

presence.on("UpdateData", async () => {
const data: PresenceData = {
largeImageKey: "cp"
},
buttons = await presence.getSetting("buttons");
largeImageKey: "cp"
},
buttons = await presence.getSetting("buttons");

if (document.location.pathname.includes("/watch")) {
const video: HTMLVideoElement = document.querySelector(".player-box video");
if (buttons) data.buttons = [{
label: 'Watch',
url: document.URL
}];
if (buttons)
data.buttons = [
{
label: "Watch",
url: document.URL
}
];
if (video && !isNaN(video.duration)) {
if (document.querySelector(".CPplayer-header-subtitle")) {
data.state =
Expand Down
2 changes: 1 addition & 1 deletion websites/D/Deezer/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"nl": "Luister altijd en overal naar alle nummers waar je van houdt."
},
"url": "www.deezer.com",
"version": "2.0.0",
"version": "2.0.1",
"logo": "https://i.imgur.com/GKMQi3h.png",
"thumbnail": "https://i.imgur.com/gVAvQ6k.png",
"color": "#A31D7C",
Expand Down
3 changes: 1 addition & 2 deletions websites/D/Deezer/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ presence.on("UpdateData", async () => {
data.details = "Browsing...";
data.state = "User's Loved";
} else if (pathname.includes("playlists")) {
data.details = "Browsing...",
data.state = "User's Playlists";
(data.details = "Browsing..."), (data.state = "User's Playlists");
} else if (pathname.includes("albums")) {
data.details = "Browsing...";
data.state = "User's Albums";
Expand Down
2 changes: 1 addition & 1 deletion websites/D/Destiny Item Manager/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"en": "Swap items, check stats, and build the loadout to Become Legend with DIM"
},
"service": "Destiny Item Manager",
"version": "1.0.0",
"version": "1.0.1",
"logo": "https://i.imgur.com/OwMBJAm.png",
"thumbnail": "https://i.imgur.com/rKhKMNY.jpg",
"color": "#ee6d0d",
Expand Down
41 changes: 24 additions & 17 deletions websites/D/Destiny Item Manager/presence.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const presence = new Presence({
clientId: "811198714726449183"
}),
clientId: "811198714726449183"
}),
browsingStamp = Math.floor(Date.now() / 1000);

presence.on("UpdateData", async () => {
Expand All @@ -12,16 +12,23 @@ presence.on("UpdateData", async () => {
if (window.location.host === "destinyitemmanager.com") {
presenceData.details = "Browsing...";
} else if (window.location.host.startsWith("app")) {
if (window.location.pathname.includes('inventory')) {
const guardian = document.querySelector(
"#content > div.inventory-container.destiny2 > div > div.store-row.store-header > div:nth-child(1) > div:nth-child(1) > div > div._2mo8C > div._1zQrq > div.ohqoA > div.FZBlR"
).textContent.trim();
if (window.location.pathname.includes("inventory")) {
const guardian = document
.querySelector(
"#content > div.inventory-container.destiny2 > div > div.store-row.store-header > div:nth-child(1) > div:nth-child(1) > div > div._2mo8C > div._1zQrq > div.ohqoA > div.FZBlR"
)
.textContent.trim();

presenceData.details = "Inventory";
presenceData.state = guardian;
presenceData.smallImageText = guardian + " - " + document.querySelector(
"#content > div.inventory-container.destiny2 > div > div.store-row.store-header > div:nth-child(1) > div:nth-child(1) > div > div._2mo8C > div._1zQrq > div.ohqoA > div._1FuuK"
).textContent.trim();
presenceData.smallImageText =
guardian +
" - " +
document
.querySelector(
"#content > div.inventory-container.destiny2 > div > div.store-row.store-header > div:nth-child(1) > div:nth-child(1) > div > div._2mo8C > div._1zQrq > div.ohqoA > div._1FuuK"
)
.textContent.trim();

if (guardian === "Titan") {
presenceData.smallImageKey = "guardian-titan";
Expand All @@ -30,21 +37,21 @@ presence.on("UpdateData", async () => {
} else if (guardian === "Hunter") {
presenceData.smallImageKey = "guardian-hunter";
}
} else if (window.location.pathname.includes('progress')) {
} else if (window.location.pathname.includes("progress")) {
presenceData.details = "Progress";
} else if (window.location.pathname.includes('vendors')) {
} else if (window.location.pathname.includes("vendors")) {
presenceData.details = "Vendors";
} else if (window.location.pathname.includes('records')) {
} else if (window.location.pathname.includes("records")) {
presenceData.details = "Records";
} else if (window.location.pathname.includes('optimizer')) {
} else if (window.location.pathname.includes("optimizer")) {
presenceData.details = "Loadout Optimizer";
} else if (window.location.pathname.includes('organizer')) {
} else if (window.location.pathname.includes("organizer")) {
presenceData.details = "Organizer";
} else if (window.location.pathname.includes('settings')) {
} else if (window.location.pathname.includes("settings")) {
presenceData.details = "Settings";
} else if (window.location.pathname.includes('about')) {
} else if (window.location.pathname.includes("about")) {
presenceData.details = "About";
} else if (window.location.pathname.includes('whats-new')) {
} else if (window.location.pathname.includes("whats-new")) {
presenceData.details = "DIM Changes";
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions websites/F/FR-Minecraft/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"fr": "L'actualité Minecraft, des astuces, des outils et toute l'aide necessaire pour jouer à Minecraft !"
},
"service": "FR-Minecraft",
"version": "1.0.0",
"version": "1.0.1",
"logo": "https://i.imgur.com/W33UNTD.png",
"thumbnail": "https://i.imgur.com/XIed4IC.png",
"color": "#4AD818",
Expand All @@ -29,4 +29,4 @@
"value": false
}
]
}
}
Loading

0 comments on commit 58f316b

Please sign in to comment.