-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
feat(appeal.gg): add activity #10962
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+240
−0
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
784d896
Create appeal.gg
JuJuplayzzz 511d93a
Delete websites/A/appeal.gg
JuJuplayzzz 4a00620
Create metadata.ts
JuJuplayzzz 2f7c76c
Create presence.ts
JuJuplayzzz b0cf0f4
Rename metadata.ts to metadata.json
JuJuplayzzz 2201f71
Update metadata.json
JuJuplayzzz 60b4a24
Update metadata.json
JuJuplayzzz f98cb94
Update metadata.json
JuJuplayzzz dba12f6
Update presence.ts
JuJuplayzzz 1e1e86f
Update websites/A/appeal.gg/metadata.json
JuJuplayzzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,40 @@ | ||
| { | ||
| "$schema": "https://schemas.premid.app/metadata/1.17", | ||
| "apiVersion": 1, | ||
| "author": { | ||
| "id": "960971439996035083", | ||
| "name": "JuJuplayz" | ||
| }, | ||
| "service": "appeal.gg", | ||
| "description": { | ||
| "en": "Discord punishment appeals standardized, for everyone." | ||
| }, | ||
| "url": [ | ||
| "appeal.gg", | ||
| "dashboard.appeal.gg" | ||
| ], | ||
| "regExp": "^https?[:][/][/]([a-z0-9-]+[.])*appeal[.]gg[/]", | ||
| "version": "1.0.0", | ||
| "logo": "https://i.imgur.com/hfCNjMe.png", | ||
| "thumbnail": "https://i.imgur.com/acs3AjP.png", | ||
| "color": "#ffbb00", | ||
| "category": "other", | ||
| "tags": [ | ||
| "bot", | ||
| "discord" | ||
| ], | ||
| "settings": [ | ||
| { | ||
| "id": "showServerInfo", | ||
| "title": "Show Server Info", | ||
| "icon": "fas fa-server", | ||
| "value": true | ||
| }, | ||
| { | ||
| "id": "enablePrivacyMode", | ||
| "title": "Privacy Mode", | ||
| "icon": "fas fa-user-secret", | ||
| "value": false | ||
| } | ||
| ] | ||
| } |
This file contains hidden or 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,200 @@ | ||
| const presence = new Presence({ | ||
| clientId: '1522240668653846630', | ||
| }) | ||
|
|
||
| enum ActivityAssets { | ||
| Logo = 'https://i.imgur.com/hfCNjMe.png', | ||
| } | ||
|
|
||
| const browsingTimestamp = Math.floor(Date.now() / 1000) | ||
|
|
||
| function getServerId(url: string): string | null { | ||
| const match = url.match(/\/(\d{17,19})(?:[/?#]|$)/) | ||
| return match ? (match[1] ?? null) : null | ||
| } | ||
|
|
||
| function getServerInfo(): { name: string, icon: string } | null { | ||
| let nameEl = document.querySelector<HTMLElement>('div.content[style*="max-width"]') | ||
| let iconEl = nameEl?.parentElement?.querySelector<HTMLImageElement>('img.icon') | ||
|
|
||
| if (!nameEl || !iconEl) { | ||
| const icons = document.querySelectorAll<HTMLImageElement>('img.icon') | ||
| for (const icon of icons) { | ||
| const possibleName = icon.parentElement?.querySelector<HTMLElement>('.content') | ||
| if (possibleName?.textContent?.trim()) { | ||
| iconEl = icon | ||
| nameEl = possibleName | ||
| break | ||
| } | ||
| } | ||
| } | ||
|
|
||
| const icon = iconEl?.src || '' | ||
| const name = nameEl?.textContent?.trim() || '' | ||
|
|
||
| if (name || icon) { | ||
| return { name: name || 'Unknown Server', icon } | ||
| } | ||
|
|
||
| return null | ||
| } | ||
|
|
||
| presence.on('UpdateData', async () => { | ||
| const rawUrl = document.location.href | ||
| const hostname = document.location.hostname | ||
| const isDashboard = hostname === 'dashboard.appeal.gg' | ||
| const fullUrl = rawUrl | ||
|
|
||
| const presenceData: PresenceData = { | ||
| largeImageKey: ActivityAssets.Logo, | ||
| } | ||
|
|
||
| const [showServerInfo, enablePrivacyMode] = await Promise.all([ | ||
| presence.getSetting<boolean>('showServerInfo'), | ||
| presence.getSetting<boolean>('enablePrivacyMode'), | ||
| ]) | ||
| const serverId = getServerId(rawUrl) | ||
|
|
||
| if (isDashboard && showServerInfo && serverId) { | ||
| const serverInfo = getServerInfo() | ||
| if (serverInfo) { | ||
| if (serverInfo.icon) { | ||
| presenceData.smallImageKey = serverInfo.icon | ||
| } | ||
| presenceData.smallImageText = serverInfo.name | ||
| } | ||
| } | ||
|
|
||
| // 1. SPECIFIC SUB-PATHS | ||
| if (fullUrl.includes('/subscription/plans')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Subscription Plans' | ||
| } | ||
| else if (fullUrl.includes('/messages/submission-info')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Messages: Submission Info' | ||
| } | ||
| else if (fullUrl.includes('/messages/log-submission-accepted')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Messages: Log Submission Accept' | ||
| } | ||
| else if (fullUrl.includes('/messages/log-submission-info')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Messages: Log Submission Create' | ||
| } | ||
| else if (fullUrl.includes('/messages/log-submission-rejected')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Messages: Log Submission Reject' | ||
| } | ||
| else if (fullUrl.includes('/messages/submission-reply-received')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Messages: Reply Received' | ||
| } | ||
| else if (fullUrl.includes('/messages/submission-reply-send-success')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Messages: Reply Send Success' | ||
| } | ||
| else if (fullUrl.includes('/messages/submission-reply-sent')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Messages: Reply Sent' | ||
| } | ||
| else if (fullUrl.includes('/messages/submission-accepted')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Messages: Submission Accepted' | ||
| } | ||
| else if (fullUrl.includes('/messages/submission-rejected')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Messages: Submission Rejected' | ||
| } | ||
|
|
||
| // 2. STANDARD MODULES & TABS | ||
| else if (fullUrl.includes('/home')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Home' | ||
| } | ||
| else if (fullUrl.includes('/subscription')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Plus Subscription' | ||
| } | ||
| else if (fullUrl.includes('/settings')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Settings' | ||
| } | ||
| else if (fullUrl.includes('/forms')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Forms' | ||
| } | ||
| else if (fullUrl.includes('/messages')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Messages' | ||
| } | ||
| else if (fullUrl.includes('/permissions')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Permissions' | ||
| } | ||
| else if (fullUrl.includes('/submissions')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Submissions' | ||
| } | ||
| else if (fullUrl.includes('/blocked-users')) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Blocked Users' | ||
| } | ||
|
|
||
| // 3. STATIC PAGES | ||
| else if (fullUrl.includes('/i/pricing')) { | ||
| presenceData.details = 'Viewing page' | ||
| presenceData.state = 'Pricing' | ||
| } | ||
| else if (fullUrl.includes('/i/terms')) { | ||
| presenceData.details = 'Viewing page' | ||
| presenceData.state = 'Terms of Service' | ||
| } | ||
| else if (fullUrl.includes('/i/privacy')) { | ||
| presenceData.details = 'Viewing page' | ||
| presenceData.state = 'Privacy Policy' | ||
| } | ||
| else if (fullUrl.includes('/i/legal-notice')) { | ||
| presenceData.details = 'Viewing page' | ||
| presenceData.state = 'Legal Notice' | ||
| } | ||
|
|
||
| // 4. HOME/ROOT FALLBACKS | ||
| else if (isDashboard) { | ||
| if (serverId) { | ||
| presenceData.details = 'Viewing dashboard' | ||
| presenceData.state = 'Server dashboard' | ||
| } | ||
| else { | ||
| presenceData.details = 'Viewing page' | ||
| presenceData.state = 'Server Selection' | ||
| } | ||
| } | ||
| else if (hostname === 'appeal.gg' && (document.location.pathname === '/' || document.location.pathname.split('/').length === 2)) { | ||
| presenceData.details = 'Viewing page' | ||
| presenceData.state = 'Home' | ||
| } | ||
| else { | ||
| presenceData.details = 'Browsing' | ||
| presenceData.state = 'Unknown page' | ||
| } | ||
|
|
||
| // Privacy Mode Override | ||
| if (enablePrivacyMode) { | ||
| presenceData.details = hostname === 'dashboard.appeal.gg' ? 'Browsing dashboard' : 'Browsing page' | ||
| delete presenceData.state | ||
| delete presenceData.smallImageKey | ||
| delete presenceData.smallImageText | ||
| } | ||
|
|
||
| // Add a timestamp | ||
| presenceData.startTimestamp = browsingTimestamp | ||
|
|
||
| // Set or clear the activity | ||
| if (presenceData.details) { | ||
| presence.setActivity(presenceData) | ||
| } | ||
| else { | ||
| presence.clearActivity() | ||
| } | ||
| }) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.