Skip to content

Commit

Permalink
Complete
Browse files Browse the repository at this point in the history
  • Loading branch information
PiggyPlex committed Apr 24, 2021
1 parent c717e2c commit 94ea9dc
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 10 deletions.
18 changes: 8 additions & 10 deletions websites/A/about.google/dist/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,20 @@
"name": "PiggyPlex",
"id": "695608126602477629"
},
"url": "www.keybr.com",
"url": "about.google",
"description": {
"en": "Teaching the world to type at the speed of thought! Typing lessons that work."
},
"service": "keybr.com",
"version": "1.0.1",
"logo": "https://i.imgur.com/5ZUdx7o.png",
"thumbnail": "https://i.imgur.com/D6gTvpU.png",
"color": "#F5F0F0",
"service": "about.google",
"version": "1.0.0",
"logo": "https://i.imgur.com/Kt0jT65.png",
"thumbnail": "https://i.imgur.com/5Xjh1EI.png",
"color": "#1a73e8",
"tags": [
"typing",
"type",
"keybr"
"google"
],
"altnames": [
"About Google"
],
"category": "games"
"category": "other"
}
78 changes: 78 additions & 0 deletions websites/A/about.google/presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const presence = new Presence({
clientId: '821847786369581066'
}),
pageMap: { [ key: string ]: { action?: string, text?: string } } = {
'': {
action: 'Reading a page:',
text: 'Homepage'
},
'google-in-uk': {
action: 'Reading about:',
text: 'Google in the UK'
},
products: {
action: 'Browsing:',
text: 'Google\'s products'
},
'extended-workforce': {
action: 'Reading about:',
text: 'Google\'s extended workforce'
},
'community-guidelines': {
action: 'Reading a page:',
text: 'Google\'s community guidelines'
},
'how-our-business-works': {
action: 'Reading about:',
text: 'How Google works'
},
'human-rights': {
action: 'Reading a page:',
text: 'Human Rights'
},
commitments: {
text: 'Commitments'
},
'commitments/racialequity': {
text: 'Racial equality'
},
stories: {
text: 'Stories'
}
};

presence.on('UpdateData', () => {
const presenceData: PresenceData = {
largeImageKey: 'logo',
details: 'Reading a page:',
state: 'Unknown page'
};
let pagename = location.pathname;
pagename = pagename.startsWith('/') ? pagename.slice(1) : pagename;
pagename = pagename.endsWith('/') ? pagename.slice(0, -1) : pagename;
let pageData = pageMap[pagename];
if (pageData && typeof pageData === 'object') {
presenceData.details = pageData.action ?? '';
presenceData.state = pageData.text ?? '';
} else if (pagename.startsWith('brand-resource-center')) {
presenceData.details = 'Brand resource center';
const metaTitle: HTMLMetaElement = document.querySelector('meta[property="og:title"]'),
h1 = document.querySelector('h1');
presenceData.state = metaTitle ? metaTitle.content : h1 ? h1.innerText : document.querySelector('title')?.innerText || '';
} else if (pagename === 'locations') {
if (location.search && location.search !== '') {
presenceData.details = 'Google\'s office locations';
presenceData.state = `in ${location.search.split('region=')[1].replace(/-/g, ' ').replace(/./, (a) => a.toUpperCase())}`;
}
location.search.split('region=')[1]
} else {
const metaTitle: HTMLMetaElement = document.querySelector('meta[property="og:title"]'),
h1 = document.querySelector('h1');
presenceData.state = metaTitle ? metaTitle.content : h1 ? h1.innerText : document.querySelector('title')?.innerText || '';
if (pagename.startsWith('stories')) {
presenceData.details = 'Reading a story:';
}
}
presence.setActivity(presenceData, true);
presence.setTrayTitle();
});

0 comments on commit 94ea9dc

Please sign in to comment.