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.
- Loading branch information
Showing
3 changed files
with
122 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$schema": "https://schemas.premid.app/metadata/1.0", | ||
"author": { | ||
"name": "Snazzah", | ||
"id": "158049329150427136" | ||
}, | ||
"url": [ | ||
"www.qwant.com", | ||
"www.qwantjunior.com" | ||
], | ||
"description": { | ||
"en": "Qwant is a search engine that respects your privacy and eases discovering and sharing via a social approach." | ||
}, | ||
"service": "Qwant", | ||
"version": "1.0.0", | ||
"logo": "https://i.imgur.com/peAp6sZ.png", | ||
"thumbnail": "https://i.imgur.com/nEMCic5.png", | ||
"color": "#4BA2EA", | ||
"tags": [ | ||
"search" | ||
], | ||
"category": "other" | ||
} |
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,93 @@ | ||
var presence = new Presence({ | ||
clientId: "719331723560878091" | ||
}); | ||
|
||
interface ItemMap { | ||
[key: string]: string; | ||
} | ||
|
||
const browsingTimestamp = Math.floor(Date.now() / 1000); | ||
|
||
const searchTypeMap: ItemMap = { | ||
web: 'Searching on the web', | ||
news: 'Searching the news', | ||
images: 'Searching images', | ||
videos: 'Searching videos', | ||
social: 'Searching social media', | ||
shopping: 'Searching for products' | ||
} | ||
|
||
const searchMusicTypeMap: ItemMap = { | ||
overview: 'Searching music', | ||
albums: 'Searching music albums', | ||
artists: 'Searching music artists', | ||
songs: 'Searching songs' | ||
} | ||
|
||
const searchJuniorTypeMap: ItemMap = { | ||
web: 'Searching on the web', | ||
images: 'Searching images', | ||
videos: 'Searching videos', | ||
education: 'Searching educational content', | ||
} | ||
|
||
presence.on("UpdateData", async () => { | ||
const data: PresenceData = { | ||
largeImageKey: "qwant", | ||
startTimestamp: browsingTimestamp | ||
}; | ||
|
||
let query: URLSearchParams = null; | ||
|
||
if (location.hostname === "www.qwant.com") { | ||
const firstPath = location.pathname.split('/')[1]; | ||
switch (firstPath) { | ||
case "": | ||
query = new URLSearchParams(location.search); | ||
if (query.has('q')) { | ||
data.details = searchTypeMap[query.get('t')]; | ||
data.state = query.get('q'); | ||
} else data.details = "Home"; | ||
break; | ||
case "music": | ||
if (location.pathname === "/music/search") { | ||
query = new URLSearchParams(location.search); | ||
data.smallImageKey = "music"; | ||
data.smallImageText = "Qwant Music"; | ||
if (query.has('q')) { | ||
data.details = searchMusicTypeMap[query.get('t')]; | ||
data.state = query.get('q'); | ||
} | ||
} else data.details = "Music Home"; | ||
break; | ||
case "maps": | ||
data.smallImageKey = "maps"; | ||
data.smallImageText = "Qwant Maps"; | ||
data.details = "Looking at maps"; | ||
break; | ||
} | ||
} else if (location.hostname === "www.qwantjunior.com") { | ||
data.largeImageKey = "qwantjunior"; | ||
query = new URLSearchParams(location.search); | ||
switch (location.pathname) { | ||
case "/": | ||
if (query.has('q')) { | ||
data.details = searchJuniorTypeMap[query.get('type')] + " in Qwant Junior"; | ||
data.state = query.get('q'); | ||
} else data.details = "Junior Home"; | ||
break; | ||
case "/news": | ||
if (query.has('q')) { | ||
data.details = "Searching the news on Qwant Junior"; | ||
data.state = query.get('q'); | ||
} else data.details = "Junior News Home"; | ||
break; | ||
} | ||
} | ||
|
||
// If data doesn't exist clear else set activity to the presence data | ||
if (data.details == null) { | ||
presence.setTrayTitle(); // Clear tray | ||
presence.setActivity(); // Clear activity | ||
} else presence.setActivity(data); | ||
}); |
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/" | ||
} | ||
} |