Skip to content

Commit

Permalink
Merge pull request PreMiD#3053 from DarkVillager/marktplaats
Browse files Browse the repository at this point in the history
Marktplaats Updated from 1.0.1 to 1.0.2
  • Loading branch information
mergify[bot] authored Feb 21, 2021
2 parents 4d532ac + 83c0482 commit 5c3f901
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 63 deletions.
14 changes: 7 additions & 7 deletions websites/M/Marktplaats/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
"name": "Dark_Ville",
"id": "638080361179512853"
},
"url": [
"www.marktplaats.nl",
"help.marktplaats.nl"
],
"url": ["www.marktplaats.nl", "help.marktplaats.nl"],
"regExp": "([a-z0-9-]+[.])*marktplaats[.]nl[/]",
"description": {
"nl": "Geniet van tweede hands producten kopen & verkopen op marktplaats!",
"en": "Enjoy buying & selling second hand products on marktplaats!"
"nl": "Ga ervoor het begint op Marktplaats.",
"en": "Go for it, it starts on Marktplaats."
},
"service": "Marktplaats",
"version": "1.0.1",
"version": "1.0.2",
"logo": "https://i.imgur.com/K0yeNeC.png",
"thumbnail": "https://i.imgur.com/xOUBejy.jpg",
"color": "#FF0000",
"tags": [
"sell",
"buy",
"secondhand",
"dutch",
"marktplaats",
"markt",
"marketplace",
"nl",
"nederlands"
Expand Down
159 changes: 103 additions & 56 deletions websites/M/Marktplaats/presence.ts
Original file line number Diff line number Diff line change
@@ -1,92 +1,138 @@
const presence = new Presence({
clientId: "811572600294735902"
}),
browsingStamp = Math.floor(Date.now() / 1000);
let search: HTMLInputElement, title: Element;
clientId: "811572600294735902"
}), browsingStamp = Math.floor(Date.now() / 1000);
let search: HTMLInputElement,
title: Element;

presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
largeImageKey: "logo"
},
page = window.location.pathname,
host = document.location.hostname;
largeImageKey: "logo"
},
page = window.location.pathname,
host = document.location.hostname;

presenceData.startTimestamp = browsingStamp;
if (host == "www.marktplaats.nl") {
presenceData.startTimestamp = browsingStamp;
if (host == "www.marktplaats.nl") {
if (page == "/") {
presenceData.details = "Viewing the homepage";
search = document.querySelector("#category-keywords");
if (search.value != "") {
presenceData.startTimestamp = browsingStamp;
presenceData.details = "Searching For:";
presenceData.state = search.value;
presenceData.smallImageKey = "searching";
} else {
presenceData.startTimestamp = browsingStamp;
presenceData.details = "Viewing:";
presenceData.state = "The homepage";
}
}
if (page == "/plaats") {
search = document.querySelector("#category-keywords");
if (search.value != "") {
presenceData.startTimestamp = browsingStamp;
presenceData.details = "Selling:";
presenceData.state = search.value;
presenceData.smallImageKey = "writing";
} else {
presenceData.startTimestamp = browsingStamp;
presenceData.details = "Viewing:";
presenceData.state = "Sell an item";
presenceData.smallImageKey = "writing";
}
}
if (page == "/m/auto/auto-verkopen/" || page == ("/m/auto/auto-verkopen")) {
presenceData.startTimestamp = browsingStamp;
presenceData.details = "Viewing:";
presenceData.state = "Selling a car";
presenceData.smallImageKey = "writing";
}
if (page.includes("/c/")) {
const numberPat = "[0-9]+",
if (page.includes("/auto-s/")) {
presenceData.details = "Viewing Category:";
presenceData.state = "Auto's";
} else {
const numberPat = '[0-9]+',
r = new RegExp("/c" + numberPat),
r2 = new RegExp("/c" + numberPat + "/");
if (r2.test(page)) {
title = document.querySelector(
"div.bucket-page.active > h2.bucket-title.heading.heading-3"
);
if (title.textContent.includes("Alle categorieën in")) {
title.textContent = title.textContent.replace(
"Alle categorieën in",
""
);
if (r2.test(page)) {
title = document.querySelector("div.bucket-page.active > h2.bucket-title.heading.heading-3");
if (title.textContent.includes("Alle categorieën in")) {
title.textContent = title.textContent.replace("Alle categorieën in", "");
}
presenceData.details = "Viewing Category:";
presenceData.state = title.textContent;
} else if (r.test(page)) {
title = document.querySelector("#content > h1");
presenceData.details = "Viewing Category:";
presenceData.state = title.textContent;
}
presenceData.details = "Viewing Category:";
presenceData.state = title.textContent;
} else if (r.test(page)) {
title = document.querySelector("#content > h1");
presenceData.details = "Viewing Category:";
presenceData.state = title.textContent;
}
} else if (page.includes("/a/")) {
title = document.querySelector("#title");
presenceData.details = "Viewing Item:";
presenceData.state = title.textContent;
} else if (page.includes("/u/")) {
title = document.querySelector(
"#content > section > div > div.mp-TopSection > div > div"
);
title = document.querySelector("#content > section > div > div.mp-TopSection > div > div");
presenceData.details = "Viewing User:";
presenceData.state = title.textContent;
}
if (page.includes("/q/")) {
search = document.querySelector("#input");
if (search.value != "") {
presenceData.startTimestamp = browsingStamp;
presenceData.details = "Searching For:";
presenceData.state = search.value;
presenceData.smallImageKey = "searching";
} else {
presenceData.startTimestamp = browsingStamp;
presenceData.details = "Viewing Items About:";
presenceData.state = window.location.href.replace("https://www.marktplaats.nl/q/", "").replace("/", "");
}
}
if (page.includes("/veilig-en-succesvol/")) {
title = document.querySelector(
"#hero-top > section > div > div.column > div > div:nth-child(1) > h1"
);
presenceData.details = "Reading about:";
presenceData.state = title.textContent;
if (page.includes("/l/auto-s/")) {
search = document.querySelector("#input");
if (search.value != "") {
presenceData.startTimestamp = browsingStamp;
presenceData.details = "Searching For:";
presenceData.state = search.value;
presenceData.smallImageKey = "searching";
} else {
presenceData.startTimestamp = browsingStamp;
presenceData.details = "Viewing:";
presenceData.state = "Auto's";
}
}
if (page.includes("/veilig-en-succesvol/")) {
title = document.querySelector("#hero-top > section > div > div.column > div > div:nth-child(1) > h1");
presenceData.details = "Reading about:";
presenceData.state = title.textContent;
presenceData.smallImageKey = "reading";
}
if (page == "/i/help/contact/") {
presenceData.details = "Reading about:";
presenceData.state = "Contact";
presenceData.smallImageKey = "reading";
} else if (page.includes("/i/help/")) {
if (
page ==
"/i/help/over-marktplaats/voorwaarden-en-privacybeleid/privacyverklaring/"
) {
if (page == "/i/help/over-marktplaats/voorwaarden-en-privacybeleid/privacyverklaring/") {
presenceData.details = "Reading about:";
presenceData.state = "Privacyverklaring";
presenceData.smallImageKey = "reading";
} else if (page.includes("/voorwaarden-en-privacybeleid/")) {
title = document.querySelector(
"#content > div.tabs-submenu > div.main-content > h3"
);
title = document.querySelector("#content > div.tabs-submenu > div.main-content > h3");
if (title == null) {
title = document.querySelector(
"#page-wrapper > div > div.content > main > h2"
);
title = document.querySelector("#page-wrapper > div > div.content > main > h2");
if (title == null) {
title = document.querySelector(
"#page-wrapper > div > div.content > main > h3"
);
title = document.querySelector("#page-wrapper > div > div.content > main > h3");
}
}
presenceData.details = "Reading about:";
presenceData.state = title.textContent;
presenceData.smallImageKey = "reading";
} else {
title = document.querySelector(
"#page-wrapper > div > div.content > main > div > h3"
);
presenceData.details = "Reading about:";
presenceData.state = title.textContent;
title = document.querySelector("#page-wrapper > div > div.content > main > div > h3");
presenceData.details = "Reading about:";
presenceData.state = title.textContent;
presenceData.smallImageKey = "reading";
}
}
if (page == "/messages") {
Expand All @@ -96,6 +142,7 @@ presence.on("UpdateData", async () => {
title = document.querySelector("div.AdvertisementSnippetMolecule-title");
presenceData.details = "Viewing messages about:";
presenceData.state = title.textContent;

}
if (page == "/notifications") {
presenceData.details = "Viewing:";
Expand Down Expand Up @@ -140,12 +187,12 @@ presence.on("UpdateData", async () => {
presenceData.state = title.textContent.replace(" | Helpdesk", "");
presenceData.smallImageKey = "reading";
}
}
}

if (presenceData.details == null) {
presence.setTrayTitle();
presence.setActivity();
} else {
presence.setActivity(presenceData);
}
});
});

0 comments on commit 5c3f901

Please sign in to comment.