Skip to content

Commit

Permalink
Media pauser
Browse files Browse the repository at this point in the history
  • Loading branch information
idematos committed Oct 31, 2024
1 parent 36f7b28 commit 006d721
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
12 changes: 12 additions & 0 deletions src/contentScript.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const pauseMedia = (): void => {
document.querySelectorAll('video, audio').forEach((media) => {

Check failure on line 2 in src/contentScript.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Delete `··`
const mediaElement = media as HTMLMediaElement

Check failure on line 3 in src/contentScript.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Delete `··`
mediaElement.pause()

Check failure on line 4 in src/contentScript.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Delete `··`
})

Check failure on line 5 in src/contentScript.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Delete `··`
}

Check failure on line 6 in src/contentScript.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Delete `··`

Check failure on line 7 in src/contentScript.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Delete `··`
browser.storage.sync.get(['status']).then((result) => {

Check failure on line 8 in src/contentScript.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Delete `··`
if (result.status) {

Check failure on line 9 in src/contentScript.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Delete `··`
pauseMedia()

Check failure on line 10 in src/contentScript.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Delete `··`
}

Check failure on line 11 in src/contentScript.ts

View workflow job for this annotation

GitHub Actions / lint-and-format

Replace `····` with `··`
})
1 change: 0 additions & 1 deletion src/popup.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ html {
--eerie-black: #1c1c1c;
--cold-gray: #9e9e9e;
--green: #bbea8d;
--white: #fff;
--font: 'Helvetica', sans-serif;

font-family: var(--font);
Expand Down
4 changes: 2 additions & 2 deletions src/popup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ document.addEventListener('DOMContentLoaded', () => {
) as HTMLInputElement
if (statusCheckbox) {
browser.storage.sync.get(['status']).then((result) => {
statusCheckbox.checked = result.status || true
statusCheckbox.checked = result.status || false
})

statusCheckbox.addEventListener('click', () => {
browser.storage.sync.set({ status: !statusCheckbox.checked })
browser.storage.sync.set({ status: statusCheckbox.checked })

document.getElementById('on-off-icon')!.style.fill =
statusCheckbox.checked ? 'var(--green)' : 'var(--cold-gray)'
Expand Down

0 comments on commit 006d721

Please sign in to comment.