Remove suffix, don't alert on download cancel

This commit is contained in:
2026-08-06 16:30:01 -05:00
parent fecc87cd66
commit f07e9f9c3a
7 changed files with 39 additions and 11 deletions

View File

@@ -33,7 +33,7 @@ WTFPL licensed.
1. Open `about:debugging#/runtime/this-firefox`
2. Click **Load Temporary Add-on...**
3. Select this extension's `manifest.json`
4. Visit `https://splice.com/sounds/search/samples`
4. Visit any URL under `https://splice.com/sounds` (for example `https://splice.com/sounds/packs/`)
## Build Firefox Package

View File

@@ -5,7 +5,7 @@ const FULL_URL_BY_SAMPLE = new Map();
const HISTORY_KEY = "capturedS3History";
const MAX_HISTORY_ITEMS = 500;
const TARGET_HOST = "splice.com";
const TARGET_PATH = "/sounds/search/samples";
const TARGET_PATH_PREFIX = "/sounds";
const AUDIO_SAMPLE_PATH_RE = /\/audio_samples\//i;
const WAVEFORM_PATH_RE = /\.wv\.json$/i;
const SCRAMBLED_PATH_RE = /-scrambled\//i;
@@ -18,7 +18,9 @@ function isDomainAllowed(pageUrl) {
}
try {
const parsed = new URL(pageUrl);
return parsed.protocol === "https:" && parsed.hostname === TARGET_HOST && parsed.pathname === TARGET_PATH;
const path = parsed.pathname || "";
const inSoundsPath = path === TARGET_PATH_PREFIX || path.startsWith(TARGET_PATH_PREFIX + "/");
return parsed.protocol === "https:" && parsed.hostname === TARGET_HOST && inSoundsPath;
} catch (error) {
return false;
}
@@ -409,7 +411,7 @@ function deriveFilename(entry, mode) {
}
return `${safeStem}.wav`;
}
return `${safeStem}_decoded.mp3`;
return `${safeStem}.mp3`;
}
async function downloadDirectUrl(url, entry) {

View File

@@ -3,7 +3,7 @@
const TARGET_SELECTOR = ".playbar-playback-info-bar.playback-row-section.svelte-11gjrk3";
const INJECTED_CONTAINER_ID = "s3-audio-capture-controls";
const TARGET_HOST = "splice.com";
const TARGET_PATH = "/sounds/search/samples";
const TARGET_PATH_PREFIX = "/sounds";
const PROBE_EVENT_SOURCE = "S3_CAPTURE_PROBE";
let knownUrls = new Set();
let knownPerformanceUrls = new Set();
@@ -21,13 +21,20 @@ let currentPlaybackCoverImageUrl = "";
let lastPlaybackMetaSignature = "";
let lastPlaybackMetaApplied = false;
function isUserCancelledError(result) {
const error = result && typeof result.error === "string" ? result.error.toLowerCase() : "";
return error.includes("canceled by the user") || error.includes("cancelled by the user");
}
function isDomainAllowed(url) {
if (typeof url !== "string") {
return false;
}
try {
const parsed = new URL(url);
return parsed.protocol === "https:" && parsed.hostname === TARGET_HOST && parsed.pathname === TARGET_PATH;
const path = parsed.pathname || "";
const inSoundsPath = path === TARGET_PATH_PREFIX || path.startsWith(TARGET_PATH_PREFIX + "/");
return parsed.protocol === "https:" && parsed.hostname === TARGET_HOST && inSoundsPath;
} catch (error) {
return false;
}
@@ -595,6 +602,9 @@ function injectControls() {
const currentButton = createButtonMetaItem("download", "Download current audio", () => {
browser.runtime.sendMessage({ type: "DOWNLOAD_LATEST" }).then((result) => {
if (!result || !result.ok) {
if (isUserCancelledError(result)) {
return;
}
window.alert((result && result.error) || "No URL available for download.");
}
}).catch(() => {

View File

@@ -4,6 +4,11 @@ const statusEl = document.getElementById("status");
const listEl = document.getElementById("historyList");
const clearHistoryBtn = document.getElementById("clearHistoryBtn");
function isUserCancelledError(result) {
const error = result && typeof result.error === "string" ? result.error.toLowerCase() : "";
return error.includes("canceled by the user") || error.includes("cancelled by the user");
}
function formatMeta(entry) {
const packName = entry && entry.packName ? entry.packName : "n/a";
const key = entry && entry.key ? entry.key : "n/a";
@@ -105,6 +110,9 @@ function buildItem(entry) {
entry
});
if (!result || !result.ok) {
if (isUserCancelledError(result)) {
return;
}
window.alert((result && result.error) || "Download failed.");
return;
}

View File

@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Splirate",
"version": "1.0.1",
"version": "1.0.2",
"description": "Splirate captures Splice sample links and downloads playable audio.",
"icons": {
"48": "icons/icon-48.png",
@@ -13,7 +13,7 @@
"storage",
"downloads",
"webRequest",
"https://splice.com/sounds/search/samples*",
"https://splice.com/sounds*",
"*://*.amazonaws.com/*",
"*://*.amazonaws.com.cn/*",
"webNavigation"
@@ -26,7 +26,7 @@
"content_scripts": [
{
"matches": [
"https://splice.com/sounds/search/samples*"
"https://splice.com/sounds*"
],
"js": [
"content-script.js"

View File

@@ -1,6 +1,6 @@
{
"name": "splirate",
"version": "1.0.1",
"version": "1.0.2",
"private": true,
"description": "Splirate Firefox extension",
"scripts": {

View File

@@ -9,6 +9,11 @@ function setStatus(message) {
statusEl.textContent = message;
}
function isUserCancelledError(result) {
const error = result && typeof result.error === "string" ? result.error.toLowerCase() : "";
return error.includes("canceled by the user") || error.includes("cancelled by the user");
}
function entryLabel(entry) {
return entry && entry.fullUrl ? "full candidate" : "preview fallback";
}
@@ -115,6 +120,9 @@ function buildRow(entry) {
download.addEventListener("click", async () => {
const result = await browser.runtime.sendMessage({ type: "DOWNLOAD_ENTRY", entry });
if (!result || !result.ok) {
if (isUserCancelledError(result)) {
return;
}
window.alert((result && result.error) || "Download failed.");
return;
}