-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: FireFox Port & Release Artifacts (#94)
* refactor: remove insertAdjacentHTML calls * refactor: get attributes using getAttribute() * styles: add firefox prefixes to stylesheet * refactor: add guards and mark async functions * refactor: Dispatcher & content-script messaging * fix: wait until video available before load * build: separate chrome & firefox manifest.json * build: move extension files into src directory * chore: remove base manifest.json * build: reset chrome manifest.json background key * styles: ungroup moz & webkit thumb styles * chore: ignore unzipped folders * ci: update release to include firefox artifact * build: set firefox min version to 109.0 * chore: correct versions to 1.5.1
- Loading branch information
Showing
58 changed files
with
234 additions
and
92 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
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 |
---|---|---|
@@ -1 +1,4 @@ | ||
*.zip | ||
*.DS_STORE | ||
Chorus-Chrome | ||
Chorus-FireFox |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,63 @@ | ||
{ | ||
"short_name": "Chorus", | ||
"name": "Chorus - Spotify Enhancer", | ||
"description": "Enhance Spotify with controls to save favourite snips, auto-skip tracks, and set global and custom speed. More to come!", | ||
"version": "1.5.1", | ||
"manifest_version": 3, | ||
"author": "cdrani", | ||
"action": {}, | ||
"icons": { | ||
"16": "icons/icon16.png", | ||
"24": "icons/icon24.png", | ||
"48": "icons/icon48.png", | ||
"64": "icons/icon64.png", | ||
"128": "icons/icon128.png" | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"run_at": "document_idle", | ||
"js": [ | ||
"utils/state.js", | ||
"content-script.js" | ||
], | ||
"css": [ | ||
"styles.css" | ||
], | ||
"matches": [ | ||
"*://open.spotify.com/*" | ||
] | ||
} | ||
], | ||
"web_accessible_resources": [ | ||
{ | ||
"matches": [ | ||
"*://open.spotify.com/*" | ||
], | ||
"resources": [ | ||
"utils/*.js", | ||
"models/*.js", | ||
"events/*.js", | ||
"components/*.js", | ||
"observers/*.js", | ||
"stores/*.js", | ||
"actions/*.js", | ||
"data/*.js" | ||
] | ||
} | ||
], | ||
"permissions": [ | ||
"activeTab", | ||
"tabs", | ||
"storage", | ||
"unlimitedStorage" | ||
], | ||
"background": { | ||
"scripts": ["background.js"] | ||
}, | ||
"browser_specific_settings": { | ||
"gecko": { | ||
"id": "chorus@cdrani.dev", | ||
"strict_min_version": "109.0" | ||
} | ||
} | ||
} |
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
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,52 @@ | ||
const loadScript = filePath => { | ||
const script = document.createElement('script') | ||
script.src = chrome.runtime.getURL(filePath) | ||
script.type = 'module' | ||
document.body.appendChild(script) | ||
} | ||
|
||
loadScript('actions/init.js') | ||
|
||
|
||
const sendEventToPage = ({ eventType, detail }) => { | ||
window.postMessage({ | ||
type: 'FROM_CONTENT_SCRIPT', | ||
requestType: eventType, | ||
payload: detail | ||
}, window.location.origin) | ||
} | ||
|
||
window.addEventListener('message', async (event) => { | ||
if (event.origin !== window.location.origin) return | ||
if (event.data.type !== 'FROM_PAGE_SCRIPT') return | ||
|
||
const { requestType, payload } = event.data | ||
let response | ||
|
||
switch (requestType) { | ||
case 'storage.set': | ||
const { key, values } = payload | ||
response = await setState({ key, values }) | ||
sendEventToPage({ eventType: 'storage.set.response', detail: response }) | ||
break | ||
|
||
case 'storage.get': | ||
response = await getState(payload) | ||
sendEventToPage({ eventType: 'storage.get.response', detail: response }) | ||
break | ||
|
||
case 'storage.delete': | ||
response = await removeState(payload.key) | ||
sendEventToPage({ eventType: 'storage.delete.response', detail: response }) | ||
break | ||
|
||
case 'storage.populate': | ||
response = await getState(null) | ||
sendEventToPage({ eventType: 'storage.populate.response', detail: response }) | ||
break | ||
} | ||
}) | ||
|
||
chrome.runtime.onMessage.addListener(message => { | ||
sendEventToPage({ eventType: 'app.enabled', detail: { enabled: message.enabled } }) | ||
}) |
File renamed without changes.
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,34 @@ | ||
export default class Dispatcher { | ||
constructor() { | ||
this.#initListener() | ||
} | ||
|
||
#initListener() { | ||
window.addEventListener('message', (event) => { | ||
if (event.origin !== window.location.origin) return | ||
|
||
if (event?.data?.type === 'FROM_CONTENT_SCRIPT') { | ||
document.dispatchEvent( | ||
new CustomEvent(event.data.requestType, { detail: event.data.payload }) | ||
) | ||
} | ||
}) | ||
} | ||
|
||
sendEvent({ eventType, detail = {} }) { | ||
window.postMessage({ | ||
type: 'FROM_PAGE_SCRIPT', | ||
requestType: eventType, | ||
payload: detail | ||
}, window.location.origin) | ||
|
||
return new Promise((resolve) => { | ||
const resultListener = (e) => { | ||
resolve(e.detail) | ||
document.removeEventListener(`${eventType}.response`, resultListener) | ||
} | ||
|
||
document.addEventListener(`${eventType}.response`, resultListener) | ||
}) | ||
} | ||
} |
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Oops, something went wrong.