change 'browser' to 'chrome' for chrome compatibility

This commit is contained in:
Wirlaburla 2024-10-11 14:22:36 -05:00
parent 781b197f17
commit 64b0c4951e
2 changed files with 5 additions and 5 deletions

View File

@ -1,15 +1,15 @@
var sndsrc; var sndsrc;
var click = new Audio(); var click = new Audio();
browser.webNavigation.onBeforeNavigate.addListener((details)=>{ chrome.webNavigation.onBeforeNavigate.addListener((details)=>{
if (!details.url.startsWith("moz-extension://") && !details.url.startsWith("about:")) { if (!details.url.startsWith("moz-extension://") && !details.url.startsWith("about:")) {
if (click.src) click.play(); if (click.src) click.play();
} }
}); });
browser.storage.local.get({sound: null}, function({sound}) { chrome.storage.local.get({sound: null}, function({sound}) {
click.src = sound; click.src = sound;
}); });
browser.storage.local.onChanged.addListener((changes)=>{ chrome.storage.local.onChanged.addListener((changes)=>{
click.src = changes.sound.newValue; click.src = changes.sound.newValue;
}); });

View File

@ -6,7 +6,7 @@ sndInput.onchange = function(event) {
reader.readAsDataURL(sndInput.files[0]); reader.readAsDataURL(sndInput.files[0]);
reader.onload = function () { reader.onload = function () {
sndTest.src = reader.result; sndTest.src = reader.result;
browser.storage.local.set({sound: reader.result}); chrome.storage.local.set({sound: reader.result});
}; };
reader.onerror = function() { reader.onerror = function() {
window.alert(reader.error); window.alert(reader.error);
@ -14,6 +14,6 @@ sndInput.onchange = function(event) {
sndInput.value = ""; sndInput.value = "";
} }
browser.storage.local.get({sound: null}, function({sound}) { chrome.storage.local.get({sound: null}, function({sound}) {
sndTest.src = sound; sndTest.src = sound;
}); });