Skip to content

Commit

Permalink
feat(LiveLinkBio): multilang, remove old sites & rewrite (PreMiD#6705)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dark_Ville authored Aug 31, 2022
1 parent 3855958 commit 8794f9f
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 64 deletions.
12 changes: 6 additions & 6 deletions websites/L/LiveLinkBio/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,8 @@
"en": "LiveLinkBio is an advanced URL Shortener Platform that allows you to easily shorten links, target your audience based on their location or platform, and provide insights on analytics for the shortened links.",
"nl": "LiveLinkBio is een geavanceerde URL Verkorter Platform, waar je makkelijk links kan verkorten, om jouw gekozen publiek te bereiken op basis van locatie en platform en het bied analytics aan voor de verkorte links."
},
"url": [
"livelinkbio.com",
"status.livelinkbio.com",
"docs.livelinkbio.com"
],
"version": "1.0.3",
"url": "livelinkbio.com",
"version": "1.1.0",
"logo": "https://i.imgur.com/mqJJ4p9.png",
"thumbnail": "https://i.imgur.com/U4DlHTe.png",
"color": "#41AAA5",
Expand All @@ -30,6 +26,10 @@
"shortener"
],
"settings": [
{
"id": "lang",
"multiLanguage": true
},
{
"id": "privacy",
"title": "Privacy Mode",
Expand Down
139 changes: 81 additions & 58 deletions websites/L/LiveLinkBio/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,84 +3,107 @@ const presence = new Presence({
}),
browsingTimestamp = Math.floor(Date.now() / 1000);

async function getStrings() {
return presence.getStrings(
{
browse: "general.browsing",
},
await presence.getSetting<string>("lang").catch(() => "en")
);
}

enum Assets {
Logo = "https://i.imgur.com/mqJJ4p9.png",
SearchImage = "https://i.imgur.com/oGQtnIY.png",
ReadingImage = "https://i.imgur.com/nese1O7.png",
}

let strings: Awaited<ReturnType<typeof getStrings>>,
oldLang: string = null;

presence.on("UpdateData", async () => {
const presenceData: PresenceData = {
largeImageKey: "logo",
largeImageKey: Assets.Logo,
startTimestamp: browsingTimestamp,
},
[privacy, buttons] = await Promise.all([
[newLang, privacy, buttons] = await Promise.all([
presence.getSetting<string>("lang").catch(() => "en"),
presence.getSetting<boolean>("privacy"),
presence.getSetting<boolean>("buttons"),
]),
search = document.querySelector<HTMLInputElement>(
"#portals-root > div:nth-child(3) > div > div > div > div > div.css-1dbjc4n.r-1ro0kt6.r-16y2uox.r-1wbh5a2 > input"
);
{ href, pathname } = document.location;

if (oldLang !== newLang || !strings) {
oldLang = newLang;
strings = await getStrings();
}
if (privacy) {
presenceData.details = strings.browse;
presence.setActivity(presenceData);
return;
}
let title: string;
if (privacy) presenceData.details = "Browsing...";
else if (document.location.hostname.includes("docs.livelinkbio.com")) {
if (search?.value) {
presenceData.details = "Searching for:";
presenceData.state = search.value;
} else {
presenceData.buttons = [
{
label: "View Docs",
url: document.location.href,
},
];
presenceData.details = "Reading docs:";
presenceData.state = document.querySelector(
"body > div.gitbook-root > div > div > div.css-1dbjc4n.r-1ro0kt6.r-16y2uox.r-1wbh5a2 > div.css-1dbjc4n.r-14lw9ot.r-13awgt0 > div > div > div.css-1dbjc4n.r-1ro0kt6.r-18u37iz.r-16y2uox.r-1wbh5a2 > div > div > div.css-1dbjc4n.r-eqz5dr.r-1ifxtd0.r-1ygmrgt > div.css-1dbjc4n.r-18u37iz > div.css-1dbjc4n.r-1ro0kt6.r-16y2uox.r-1wbh5a2 > div"
).textContent;
const type = document.querySelector(
"body > main > section > div.row.mb-4 > div.col-12.col-lg.d-flex.align-items-center.mb-3.mb-lg-0 > h1"
),
active =
document.querySelector('[class="nav-link active"]') ??
document.querySelector('[class="active"]');
switch (pathname.split("/")[1]) {
case "": {
presenceData.details = "Homepage";
break;
}
} else if (document.location.hostname.includes("status.livelinkbio.com"))
presenceData.details = "Status";
else {
const type = document.querySelector(
"body > main > section > div.row.mb-4 > div.col-12.col-lg.d-flex.align-items-center.mb-3.mb-lg-0 > h1"
),
active = document.querySelector('[class="nav-link active"]');
if (document.location.pathname === "/") presenceData.details = "Homepage";
else if (document.location.pathname.includes("affiliate")) {
case "affiliate": {
presenceData.buttons = [
{
label: "View Affiliates",
url: document.location.href,
url: href,
},
];
presenceData.details = "Affiliate";
} else if (document.location.pathname.includes("dashboard")) {
presenceData.details = "Dashboard";
presenceData.details = "Viewing affiliates";
break;
}
case "dashboard": {
presenceData.details = "Viewing the dashboard";
presenceData.buttons = [
{
label: "View Dashboard",
url: document.location.href,
url: href,
},
];
} else if (document.location.pathname.includes("link")) {
break;
}
case "link": {
presenceData.state = document.querySelector("#link_url").textContent;
if (document.location.pathname.endsWith("statistics"))
presenceData.details = "Statistics of link:";
else presenceData.details = "Editing link:";
} else if (document.querySelector("body").className.includes("open")) {
title = document
.querySelectorAll('[class="modal-title"]')[1]
.textContent.replace("Edit", "");
presenceData.details = `${title}:`;
presenceData.state =
document.querySelector<HTMLInputElement>("#update_name").value;
} else if (type && !active) {
title = type.textContent.trim();
presenceData.buttons = [
{
label: "View all",
url: document.location.href,
},
];
presenceData.details = `All ${title}`;
} else if (active) {
title = active.textContent.trim();
presenceData.details = title;
if (pathname.endsWith("statistics"))
presenceData.details = "Viewing statistics of link";
else presenceData.details = "Editing link";
break;
}
case "tools": {
if (active) presenceData.details = `Using ${active.textContent}`;
else presenceData.details = "Viewing all tools";
break;
}
default: {
if (document.querySelector("body").className.includes("open")) {
title = document
.querySelectorAll('[class="modal-title"]')[1]
.textContent.replace("Edit", "");
presenceData.details = title;
presenceData.state =
document.querySelector<HTMLInputElement>("#update_name").value;
} else if (type && !active) {
title = type.textContent.trim();
presenceData.buttons = [
{
label: "View All",
url: href,
},
];
presenceData.details = `Viewing all ${title}`;
} else if (active) presenceData.details = active.textContent.trim();
}
}
if (!buttons) delete presenceData.buttons;
Expand Down

0 comments on commit 8794f9f

Please sign in to comment.