1.0 commit

This commit is contained in:
Wirlaburla 2024-10-11 13:23:03 -05:00
parent 4cabb1830b
commit 71405eb0b0
7 changed files with 101 additions and 1 deletions

View File

@ -1,3 +1,2 @@
# ClickSnd # ClickSnd
Firefox add-on that plays a custom sound on link click or page load Firefox add-on that plays a custom sound on link click or page load

15
click.js Normal file
View File

@ -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;
});

BIN
icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

29
manifest.json Normal file
View File

@ -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"
}
}
}

12
options.css Normal file
View File

@ -0,0 +1,12 @@
body {
display: flex;
justify-content: center;
}
#group > div {
display: flex;
gap: 4px;
margin: 4px;
}
#test_results, #exeinput {
flex-grow: 1;
}

26
options.html Normal file
View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ClickSnd Options</title>
<link rel="icon" type="image/png" href="images/16.png" />
</head>
<body>
<table>
<tr>
<th rowspan="2"><img width="48" height="48" src="icon.png" /></th>
<td><font size="5"><strong>ClickSnd</strong></font></td>
</tr>
<tr>
<td>Options</td>
</tr>
</table>
<hr />
<dl>
<dt><audio name="sndtest" src="data:audio/wav;base64,UklGRigAAABXQVZFZm10IBAAAAABAAEAgLsAAAB3AQACABAAZGF0YQQAAAAAAAAA" controls></audio></dt>
<dt><input name="sndfile" type="file" accept="audio/*" /></dt>
</dl>
<script type="text/javascript" src="options.js"></script>
</body>
</html>

19
options.js Normal file
View File

@ -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;
});