File tree Expand file tree Collapse file tree 5 files changed +57
-1
lines changed Expand file tree Collapse file tree 5 files changed +57
-1
lines changed Original file line number Diff line number Diff line change 1
- node_modules /
1
+ node_modules
2
2
package-lock.json
3
3
Activity.js
Original file line number Diff line number Diff line change
1
+ import type { Activity } from '@/Activity.ts'
2
+
3
+
4
+ const getFaviconUrl = ( ) => {
5
+ const linkElements = Array . from (
6
+ document . head . querySelectorAll < HTMLLinkElement > ( "link[rel*='icon']" )
7
+ )
8
+
9
+ for ( const link of linkElements )
10
+ if ( link . href ) return link . href
11
+
12
+ return `${ window . location . origin } /favicon.ico`
13
+ }
14
+
15
+ const getPageDescription = ( ) => {
16
+ const metaDescription = document . querySelector < HTMLMetaElement > ( "meta[name='description']" )
17
+ return metaDescription ? metaDescription . content : null
18
+ }
19
+
20
+
21
+ const presence : Activity = {
22
+ timestamps : { start : Date . now ( ) }
23
+ }
24
+
25
+ bambloo . onMessage . addListener ( msg => {
26
+ if ( msg . type !== 'start' ) return
27
+
28
+ presence . assets = {
29
+ large_image : getFaviconUrl ( )
30
+ }
31
+ presence . state = document . title
32
+ presence . details = getPageDescription ( ) || ''
33
+
34
+ bambloo . update ( presence )
35
+ } )
Original file line number Diff line number Diff line change
1
+ {
2
+ "title" : " Generic" ,
3
+ "description" : " Generic presence script for all websites" ,
4
+ "author" : " elisoli" ,
5
+
6
+ "title_color" : " #050505" ,
7
+
8
+ "images" : {
9
+ "background" : " ./background.jpg" ,
10
+ "icon" : " ./icon.svg"
11
+ },
12
+
13
+ "previews" : [],
14
+
15
+ "urls" : [ " <all_urls>" ],
16
+
17
+ "script" : " main.js"
18
+ }
You can’t perform that action at this time.
0 commit comments