diff --git a/README.md b/README.md index dadd10b..df48f2c 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,2 @@ # ClickSnd - Firefox add-on that plays a custom sound on link click or page load \ No newline at end of file diff --git a/click.js b/click.js new file mode 100644 index 0000000..29271a8 --- /dev/null +++ b/click.js @@ -0,0 +1,15 @@ +var sndsrc; +var click = new Audio(); +browser.webNavigation.onBeforeNavigate.addListener((details)=>{ + if (!details.url.startsWith("moz-extension://") && !details.url.startsWith("about:")) { + if (click.src) click.play(); + } +}); + +browser.storage.local.get({sound: null}, function({sound}) { + click.src = sound; +}); + +browser.storage.local.onChanged.addListener((changes)=>{ + click.src = changes.sound.newValue; +}); \ No newline at end of file diff --git a/icon.png b/icon.png new file mode 100644 index 0000000..82d9f24 Binary files /dev/null and b/icon.png differ diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..3e438ae --- /dev/null +++ b/manifest.json @@ -0,0 +1,29 @@ +{ + "manifest_version": 2, + "name": "ClickSnd", + "version": "1.0", + "description": "Plays a click sound when you click on a link.", + "icons": { + "48": "icon.png" + }, + "background": { + "scripts": [ + "click.js" + ] + }, + "permissions": [ + "webNavigation", + "storage" + ], + "options_ui": { + "browser_style": false, + "open_in_tab": true, + "page": "options.html" + }, + "browser_specific_settings": { + "gecko": { + "id": "clicksnd@wirlaburla.worlio.com", + "update_url": "https://wirlaburla.worlio.com/software/browser-addons/updates.json" + } + } +} \ No newline at end of file diff --git a/options.css b/options.css new file mode 100644 index 0000000..a86e28f --- /dev/null +++ b/options.css @@ -0,0 +1,12 @@ +body { + display: flex; + justify-content: center; +} +#group > div { + display: flex; + gap: 4px; + margin: 4px; +} +#test_results, #exeinput { + flex-grow: 1; +} \ No newline at end of file diff --git a/options.html b/options.html new file mode 100644 index 0000000..ea34b2e --- /dev/null +++ b/options.html @@ -0,0 +1,26 @@ + + + + +ClickSnd Options + + + + + + + + + + + +
ClickSnd
Options
+
+
+
+
+
+ + + + diff --git a/options.js b/options.js new file mode 100644 index 0000000..2499554 --- /dev/null +++ b/options.js @@ -0,0 +1,19 @@ +let sndInput = document.querySelector('input[name="sndfile"]'); +let sndTest = document.querySelector('audio[name="sndtest"]'); + +sndInput.onchange = function(event) { + var reader = new FileReader(); + reader.readAsDataURL(sndInput.files[0]); + reader.onload = function () { + sndTest.src = reader.result; + browser.storage.local.set({sound: reader.result}); + }; + reader.onerror = function() { + window.alert(reader.error); + } + sndInput.value = ""; +} + +browser.storage.local.get({sound: null}, function({sound}) { + sndTest.src = sound; +}); \ No newline at end of file