Build scripts

This commit is contained in:
2026-08-05 22:59:23 -05:00
parent 4f10991abc
commit cee9f6a02f
18 changed files with 183 additions and 338 deletions

View File

@@ -4,7 +4,8 @@ const TAB_CAPTURED = new Map();
const FULL_URL_BY_SAMPLE = new Map();
const HISTORY_KEY = "capturedS3History";
const MAX_HISTORY_ITEMS = 500;
const SPLICE_DOMAIN_RE = /^https?:\/\/([a-z0-9-]+\.)*splice\.com(\/|$)/i;
const TARGET_HOST = "splice.com";
const TARGET_PATH = "/sounds/search/samples";
const AUDIO_SAMPLE_PATH_RE = /\/audio_samples\//i;
const WAVEFORM_PATH_RE = /\.wv\.json$/i;
const SCRAMBLED_PATH_RE = /-scrambled\//i;
@@ -12,7 +13,15 @@ const HASH_RE = /^[a-f0-9]{64}$/i;
const GRAPHQL_URL = "https://surfaces-graphql.splice.com/graphql";
function isDomainAllowed(pageUrl) {
return typeof pageUrl === "string" && SPLICE_DOMAIN_RE.test(pageUrl);
if (typeof pageUrl !== "string") {
return false;
}
try {
const parsed = new URL(pageUrl);
return parsed.protocol === "https:" && parsed.hostname === TARGET_HOST && parsed.pathname === TARGET_PATH;
} catch (error) {
return false;
}
}
function isS3Url(url) {
@@ -825,8 +834,19 @@ function handleWebRequestCapture(details) {
}
const tabId = typeof details.tabId === "number" ? details.tabId : -1;
const merged = upsertUrl(tabId, url, "webrequest");
void merged;
if (tabId < 0) {
return;
}
browser.tabs.get(tabId).then((tab) => {
const tabUrl = tab && typeof tab.url === "string" ? tab.url : "";
if (!isDomainAllowed(tabUrl)) {
return;
}
const merged = upsertUrl(tabId, url, "webrequest");
void merged;
}).catch(() => {
// Ignore tab lookup failures.
});
}
browser.webRequest.onBeforeRequest.addListener(