Compare commits
8
Commits
bb1a938cc0
...
ext-1.0.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b5ec86222 | ||
|
|
d80a5255ed | ||
|
|
89c83ee5de | ||
|
|
69b5637bd6 | ||
|
|
d3192f1843 | ||
|
|
51749e05db | ||
|
|
5a5694f200 | ||
|
|
50d6c42207 |
@@ -35,9 +35,14 @@ class InvalidUrlError(Exception):
|
|||||||
# reviewers catch drift.
|
# reviewers catch drift.
|
||||||
_PLATFORM_PATTERNS: list[tuple[str, re.Pattern[str]]] = [
|
_PLATFORM_PATTERNS: list[tuple[str, re.Pattern[str]]] = [
|
||||||
("patreon", re.compile(
|
("patreon", re.compile(
|
||||||
|
# Three creator URL shapes — bare (patreon.com/Atole), `c/`, and `cw/`
|
||||||
|
# (the "creator workspace" URL served once subscribed, see
|
||||||
|
# patreon_resolver._VANITY_RE). A trailing sub-path is allowed so a
|
||||||
|
# creator's inner page still derives the slug. Nav pages stay excluded.
|
||||||
r"^https?://(?:www\.)?patreon\.com/"
|
r"^https?://(?:www\.)?patreon\.com/"
|
||||||
r"(?!home$|search\b|messages\b|notifications\b|library\b|settings\b|posts\b|c/)"
|
r"(?:cw/|c/)?"
|
||||||
r"(?P<slug>[^/?#]+)/?$",
|
r"(?!(?:home|search|messages|notifications|library|settings|posts)(?:[/?#]|$))"
|
||||||
|
r"(?P<slug>[^/?#]+)",
|
||||||
re.IGNORECASE,
|
re.IGNORECASE,
|
||||||
)),
|
)),
|
||||||
("subscribestar", re.compile(
|
("subscribestar", re.compile(
|
||||||
|
|||||||
@@ -31,6 +31,69 @@ browser.runtime.onInstalled.addListener(() => ensureInitialized());
|
|||||||
browser.runtime.onStartup.addListener(() => ensureInitialized());
|
browser.runtime.onStartup.addListener(() => ensureInitialized());
|
||||||
ensureInitialized().catch(e => console.error('init failed:', e));
|
ensureInitialized().catch(e => console.error('init failed:', e));
|
||||||
|
|
||||||
|
// ---- Extension self-update check (#1489) ----
|
||||||
|
// Installed per-instance from the operator's FC host, so Firefox's static
|
||||||
|
// update_url can't apply (each instance has a different host). Instead ask the
|
||||||
|
// configured backend for the latest published version and nudge the operator to
|
||||||
|
// reinstall the freshly-signed XPI — surfaced as a popup banner (on demand) and
|
||||||
|
// a toolbar badge (daily). /api/extension/manifest is public and returns
|
||||||
|
// {version, latest_url, sha256}; the XPI is served from the web root (not /api).
|
||||||
|
|
||||||
|
function versionIsNewer(candidate, current) {
|
||||||
|
// Dotted numeric compare so 1.0.10 > 1.0.9 (a plain string compare wouldn't).
|
||||||
|
const a = String(candidate).split('.').map(n => parseInt(n, 10) || 0);
|
||||||
|
const b = String(current).split('.').map(n => parseInt(n, 10) || 0);
|
||||||
|
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
||||||
|
if ((a[i] || 0) !== (b[i] || 0)) return (a[i] || 0) > (b[i] || 0);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function checkForUpdateInfo() {
|
||||||
|
await ensureInitialized();
|
||||||
|
if (!api.isConfigured()) return { updateAvailable: false, configured: false };
|
||||||
|
let info;
|
||||||
|
try {
|
||||||
|
info = await api.getExtensionManifest();
|
||||||
|
} catch (e) {
|
||||||
|
return { updateAvailable: false, error: e.message };
|
||||||
|
}
|
||||||
|
const currentVersion = browser.runtime.getManifest().version;
|
||||||
|
const latestVersion = info && info.version ? info.version : null;
|
||||||
|
// latest_url is served from the web root; strip the /api suffix off baseUrl
|
||||||
|
// (same transform as OPEN_ARTIST_PAGE).
|
||||||
|
const base = (api.baseUrl || '').replace(/\/+$/, '').replace(/\/api$/, '');
|
||||||
|
return {
|
||||||
|
updateAvailable: !!latestVersion && versionIsNewer(latestVersion, currentVersion),
|
||||||
|
currentVersion,
|
||||||
|
latestVersion,
|
||||||
|
xpiUrl: info && info.latest_url ? `${base}${info.latest_url}` : null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
async function refreshUpdateBadge() {
|
||||||
|
let r;
|
||||||
|
try { r = await checkForUpdateInfo(); } catch { return; }
|
||||||
|
try {
|
||||||
|
await browser.action.setBadgeText({ text: r.updateAvailable ? '↑' : '' });
|
||||||
|
if (r.updateAvailable) {
|
||||||
|
await browser.action.setBadgeBackgroundColor({ color: '#F4BA7A' });
|
||||||
|
await browser.action.setTitle({ title: `FabledCurator — update available (v${r.latestVersion})` });
|
||||||
|
} else {
|
||||||
|
await browser.action.setTitle({ title: 'FabledCurator' });
|
||||||
|
}
|
||||||
|
} catch { /* action API unavailable — non-fatal */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
// Daily proactive check (needs the "alarms" permission). create() is idempotent
|
||||||
|
// by name, so re-running it on each event-page load is safe.
|
||||||
|
browser.alarms.create('fc-update-check', { periodInMinutes: 24 * 60, delayInMinutes: 1 });
|
||||||
|
browser.alarms.onAlarm.addListener((alarm) => {
|
||||||
|
if (alarm.name === 'fc-update-check') refreshUpdateBadge();
|
||||||
|
});
|
||||||
|
browser.runtime.onStartup.addListener(() => refreshUpdateBadge());
|
||||||
|
browser.runtime.onInstalled.addListener(() => refreshUpdateBadge());
|
||||||
|
|
||||||
// ---- Discord token capture via webRequest ----
|
// ---- Discord token capture via webRequest ----
|
||||||
|
|
||||||
browser.webRequest.onBeforeSendHeaders.addListener(
|
browser.webRequest.onBeforeSendHeaders.addListener(
|
||||||
@@ -298,6 +361,9 @@ browser.runtime.onMessage.addListener(async (msg) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case 'CHECK_UPDATE':
|
||||||
|
return await checkForUpdateInfo();
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return { error: `Unknown message type: ${msg.type}` };
|
return { error: `Unknown message type: ${msg.type}` };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -89,6 +89,12 @@ class FabledCuratorAPI {
|
|||||||
const qs = new URLSearchParams({ url }).toString();
|
const qs = new URLSearchParams({ url }).toString();
|
||||||
return this.request('GET', `/extension/probe?${qs}`);
|
return this.request('GET', `/extension/probe?${qs}`);
|
||||||
}
|
}
|
||||||
|
// Latest published extension version on this instance — drives the in-app
|
||||||
|
// update prompt. Public endpoint (no key needed, but request() sends it
|
||||||
|
// harmlessly). Returns {version, xpi_url, latest_url, sha256}.
|
||||||
|
getExtensionManifest() {
|
||||||
|
return this.request('GET', '/extension/manifest');
|
||||||
|
}
|
||||||
|
|
||||||
// Connection test = the cheapest read with auth.
|
// Connection test = the cheapest read with auth.
|
||||||
testConnection() {
|
testConnection() {
|
||||||
|
|||||||
@@ -86,7 +86,16 @@ const PLATFORMS = {
|
|||||||
* script to decide whether to show the floating "Add as source" button.
|
* script to decide whether to show the floating "Add as source" button.
|
||||||
*/
|
*/
|
||||||
const PLATFORM_ARTIST_PATTERNS = {
|
const PLATFORM_ARTIST_PATTERNS = {
|
||||||
patreon: /^https?:\/\/(www\.)?patreon\.com\/(?!home$|search\b|messages\b|notifications\b|library\b|settings\b|posts\b|c\/)[^/?#]+\/?$/i,
|
// Patreon serves the same creator under three URL shapes (see backend
|
||||||
|
// patreon_resolver._VANITY_RE): bare `patreon.com/Atole`, `c/` prefix, and
|
||||||
|
// `cw/` "creator workspace" — the last is the URL you land on once you're
|
||||||
|
// SUBSCRIBED, which is exactly when the button matters. Match all three, and
|
||||||
|
// drop the single-segment end-anchor so a creator's inner page
|
||||||
|
// (…/cw/Atole/posts, …/Atole/membership) also injects the button. Nav pages
|
||||||
|
// (home/search/…/posts permalink) stay excluded. Mirrors extension_service
|
||||||
|
// ._PLATFORM_PATTERNS — keep in sync (operator-flagged 2026-07-13: button
|
||||||
|
// vanished once subscribed because the old pattern only matched the bare root).
|
||||||
|
patreon: /^https?:\/\/(www\.)?patreon\.com\/(?:cw\/|c\/)?(?!(?:home|search|messages|notifications|library|settings|posts)(?:[\/?#]|$))[^/?#]+/i,
|
||||||
subscribestar: /^https?:\/\/(www\.)?subscribestar\.(com|adult)\/(?!feed$|messages$|library$)[^/?#]+\/?$/i,
|
subscribestar: /^https?:\/\/(www\.)?subscribestar\.(com|adult)\/(?!feed$|messages$|library$)[^/?#]+\/?$/i,
|
||||||
hentaifoundry: /^https?:\/\/(www\.)?hentai-foundry\.com\/user\/[^/?#]+/i,
|
hentaifoundry: /^https?:\/\/(www\.)?hentai-foundry\.com\/user\/[^/?#]+/i,
|
||||||
deviantart: /^https?:\/\/(www\.)?deviantart\.com\/(?!home$|watch\b|tag\b|browse\b)[^/?#]+\/?$/i,
|
deviantart: /^https?:\/\/(www\.)?deviantart\.com\/(?!home$|watch\b|tag\b|browse\b)[^/?#]+\/?$/i,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"manifest_version": 3,
|
"manifest_version": 3,
|
||||||
"name": "FabledCurator",
|
"name": "FabledCurator",
|
||||||
"version": "1.0.7",
|
"version": "1.0.9",
|
||||||
"description": "Export cookies from supported platforms to FabledCurator and add creators as sources in one click.",
|
"description": "Export cookies from supported platforms to FabledCurator and add creators as sources in one click.",
|
||||||
|
|
||||||
"browser_specific_settings": {
|
"browser_specific_settings": {
|
||||||
@@ -22,7 +22,8 @@
|
|||||||
"tabs",
|
"tabs",
|
||||||
"activeTab",
|
"activeTab",
|
||||||
"webRequest",
|
"webRequest",
|
||||||
"webRequestBlocking"
|
"webRequestBlocking",
|
||||||
|
"alarms"
|
||||||
],
|
],
|
||||||
|
|
||||||
"host_permissions": [
|
"host_permissions": [
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "fabledcurator-extension",
|
"name": "fabledcurator-extension",
|
||||||
"version": "1.0.7",
|
"version": "1.0.9",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Firefox extension for FabledCurator",
|
"description": "Firefox extension for FabledCurator",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@@ -10,6 +10,6 @@
|
|||||||
"sign": "web-ext sign --source-dir=. --no-config-discovery --ignore-files package.json package-lock.json web-ext-artifacts node_modules README.md .gitignore --channel=unlisted --api-key=$WEB_EXT_API_KEY --api-secret=$WEB_EXT_API_SECRET"
|
"sign": "web-ext sign --source-dir=. --no-config-discovery --ignore-files package.json package-lock.json web-ext-artifacts node_modules README.md .gitignore --channel=unlisted --api-key=$WEB_EXT_API_KEY --api-secret=$WEB_EXT_API_SECRET"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"web-ext": "^8.0.0"
|
"web-ext": "^10.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,17 @@ body {
|
|||||||
.btn.block { display: block; width: 100%; margin-top: 8px; }
|
.btn.block { display: block; width: 100%; margin-top: 8px; }
|
||||||
.btn.link { background: none; color: var(--on-surface-variant); padding: 4px; }
|
.btn.link { background: none; color: var(--on-surface-variant); padding: 4px; }
|
||||||
.btn.link:hover { color: var(--accent); }
|
.btn.link:hover { color: var(--accent); }
|
||||||
|
.btn.small { padding: 6px 12px; font-size: 13px; }
|
||||||
|
|
||||||
|
/* In-app update prompt (accent-tinted so it reads as an actionable notice). */
|
||||||
|
.update-banner {
|
||||||
|
display: flex; align-items: center; gap: 10px;
|
||||||
|
margin: 10px 10px 0; padding: 10px 12px;
|
||||||
|
background: rgba(244, 186, 122, 0.12);
|
||||||
|
border: 1px solid rgba(244, 186, 122, 0.4);
|
||||||
|
border-radius: 6px;
|
||||||
|
}
|
||||||
|
#update-text { flex: 1; font-size: 13px; }
|
||||||
|
|
||||||
.source-row .play {
|
.source-row .play {
|
||||||
background: none; border: none; color: var(--on-surface-variant);
|
background: none; border: none; color: var(--on-surface-variant);
|
||||||
|
|||||||
@@ -20,6 +20,11 @@
|
|||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="main-content" class="main hidden">
|
<section id="main-content" class="main hidden">
|
||||||
|
<div id="update-banner" class="update-banner hidden">
|
||||||
|
<span id="update-text"></span>
|
||||||
|
<button id="update-btn" class="btn primary small">Update</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
<nav class="tabs">
|
<nav class="tabs">
|
||||||
<button class="tab active" data-tab="platforms">Platforms</button>
|
<button class="tab active" data-tab="platforms">Platforms</button>
|
||||||
<button class="tab" data-tab="sources">Sources</button>
|
<button class="tab" data-tab="sources">Sources</button>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ async function init() {
|
|||||||
setupEventListeners();
|
setupEventListeners();
|
||||||
showPlatformsLoading();
|
showPlatformsLoading();
|
||||||
testConnectionIfNeeded();
|
testConnectionIfNeeded();
|
||||||
|
checkForUpdate();
|
||||||
loadPlatformStatus().catch(e => showError(`Failed to load platforms: ${e.message}`));
|
loadPlatformStatus().catch(e => showError(`Failed to load platforms: ${e.message}`));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
showSetupRequired();
|
showSetupRequired();
|
||||||
@@ -63,6 +64,26 @@ function updateConnectionDot(connected) {
|
|||||||
d.title = connected ? 'Connected to FabledCurator' : 'Disconnected';
|
d.title = connected ? 'Connected to FabledCurator' : 'Disconnected';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Nudge to reinstall when the configured instance publishes a newer signed XPI
|
||||||
|
// (the extension is self-hosted, so there's no Firefox auto-update). Never
|
||||||
|
// blocks the popup — a failed check just leaves the banner hidden.
|
||||||
|
async function checkForUpdate() {
|
||||||
|
try {
|
||||||
|
const r = await browser.runtime.sendMessage({ type: 'CHECK_UPDATE' });
|
||||||
|
if (r && r.updateAvailable && r.xpiUrl) showUpdateBanner(r);
|
||||||
|
} catch { /* non-fatal */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
function showUpdateBanner(r) {
|
||||||
|
document.getElementById('update-text').textContent =
|
||||||
|
`Update available — v${r.latestVersion} (installed v${r.currentVersion})`;
|
||||||
|
// Opening the signed XPI triggers Firefox's native install prompt.
|
||||||
|
document.getElementById('update-btn').addEventListener('click', () => {
|
||||||
|
browser.tabs.create({ url: r.xpiUrl });
|
||||||
|
});
|
||||||
|
document.getElementById('update-banner').classList.remove('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
async function loadPlatformStatus() {
|
async function loadPlatformStatus() {
|
||||||
const status = await browser.runtime.sendMessage({ type: 'GET_PLATFORM_STATUS' });
|
const status = await browser.runtime.sendMessage({ type: 'GET_PLATFORM_STATUS' });
|
||||||
const c = document.getElementById('platforms-list');
|
const c = document.getElementById('platforms-list');
|
||||||
|
|||||||
@@ -145,12 +145,17 @@ const health = computed(() => {
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
padding: 0.75rem 1rem;
|
padding: 0.75rem 1rem;
|
||||||
/* Obsidian (#14171A = 20,23,26) gradient fade — content scrolls under it. */
|
/* Obsidian (#14171A) fade — content scrolls under it. Holds high (0.92 →
|
||||||
|
0.84) through the top half, then eases to transparent over the bottom
|
||||||
|
quarter so it tails off softly instead of a straight line to a hard edge
|
||||||
|
(operator 2026-07-13). Shared --fc-chrome-rgb keeps it in sync with the
|
||||||
|
sub-header continuation. */
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
to bottom,
|
to bottom,
|
||||||
rgba(20, 23, 26, 0.92) 0%,
|
rgba(var(--fc-chrome-rgb), 0.92) 0%,
|
||||||
rgba(20, 23, 26, 0.65) 60%,
|
rgba(var(--fc-chrome-rgb), 0.84) 50%,
|
||||||
rgba(20, 23, 26, 0) 100%
|
rgba(var(--fc-chrome-rgb), 0.55) 75%,
|
||||||
|
rgba(var(--fc-chrome-rgb), 0) 100%
|
||||||
);
|
);
|
||||||
backdrop-filter: blur(2px);
|
backdrop-filter: blur(2px);
|
||||||
-webkit-backdrop-filter: blur(2px);
|
-webkit-backdrop-filter: blur(2px);
|
||||||
@@ -165,7 +170,7 @@ const health = computed(() => {
|
|||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
to bottom,
|
to bottom,
|
||||||
rgba(var(--fc-chrome-rgb), 0.92) 0%,
|
rgba(var(--fc-chrome-rgb), 0.92) 0%,
|
||||||
rgba(var(--fc-chrome-rgb), 0.72) 55%,
|
rgba(var(--fc-chrome-rgb), 0.84) 60%,
|
||||||
rgba(var(--fc-chrome-rgb), var(--fc-chrome-seam)) 100%
|
rgba(var(--fc-chrome-rgb), var(--fc-chrome-seam)) 100%
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -331,6 +331,20 @@ function pushFilter(mutate) {
|
|||||||
.fc-filterbar-wrap :deep(.v-btn-group) {
|
.fc-filterbar-wrap :deep(.v-btn-group) {
|
||||||
background-color: rgba(20, 23, 26, 0.72);
|
background-color: rgba(20, 23, 26, 0.72);
|
||||||
}
|
}
|
||||||
|
/* Media toggle (All / Images / Videos) as ONE cohesive segmented control.
|
||||||
|
FC's global VBtn { rounded: 'pill' } default made Vuetify 4 pill-round each
|
||||||
|
SEGMENT individually, so the rounded ends collided at the joins — the shapes
|
||||||
|
landed awkwardly on the button edges (operator 2026-07-13). Square the inner
|
||||||
|
segments (over the pill utility's !important) and clip the group to a single
|
||||||
|
8px outline (matches the chips/tiles rounding elsewhere in the app). Radius
|
||||||
|
only — no height change, so the bar height and nav offset are untouched. */
|
||||||
|
.fc-filterbar-wrap :deep(.v-btn-toggle) {
|
||||||
|
border-radius: 8px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.fc-filterbar-wrap :deep(.v-btn-toggle .v-btn) {
|
||||||
|
border-radius: 0 !important;
|
||||||
|
}
|
||||||
.fc-filterbar__search { max-width: 320px; min-width: 200px; }
|
.fc-filterbar__search { max-width: 320px; min-width: 200px; }
|
||||||
.fc-filterbar__chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
|
.fc-filterbar__chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
|
||||||
/* The tag chips' bodies toggle include/exclude — signal they're clickable. */
|
/* The tag chips' bodies toggle include/exclude — signal they're clickable. */
|
||||||
|
|||||||
@@ -77,7 +77,13 @@
|
|||||||
legible tabs/controls over scrolling content), lower it for a lighter fade. */
|
legible tabs/controls over scrolling content), lower it for a lighter fade. */
|
||||||
:root {
|
:root {
|
||||||
--fc-chrome-rgb: 20, 23, 26; /* obsidian #14171A — matches the TopNav */
|
--fc-chrome-rgb: 20, 23, 26; /* obsidian #14171A — matches the TopNav */
|
||||||
--fc-chrome-seam: 0.46; /* alpha where the nav hands off to the sub-header */
|
/* Alpha where the nav hands off to the sub-header — also the "hold" level of
|
||||||
|
the fade. The chrome stays fairly opaque (0.92 → this) through the bulk of
|
||||||
|
its height, then drops to transparent in a small eased section at the very
|
||||||
|
bottom (see the multi-stop gradients), so it reads as a slow falloff that
|
||||||
|
tails off softly rather than a straight line to a hard edge (operator
|
||||||
|
2026-07-13). Raise for heavier/more-legible chrome, lower for a lighter fade. */
|
||||||
|
--fc-chrome-seam: 0.68;
|
||||||
/* Actual TopNav height, measured live (ResizeObserver in TopNav.vue) and used
|
/* Actual TopNav height, measured live (ResizeObserver in TopNav.vue) and used
|
||||||
by full-height workspaces (Explore/Subscriptions: calc(100vh - var)) and by
|
by full-height workspaces (Explore/Subscriptions: calc(100vh - var)) and by
|
||||||
every sticky sub-header pinned beneath the nav (top: var). This was a
|
every sticky sub-header pinned beneath the nav (top: var). This was a
|
||||||
@@ -92,9 +98,16 @@
|
|||||||
controls legible as the fill thins toward transparent — the solid-surface
|
controls legible as the fill thins toward transparent — the solid-surface
|
||||||
bars it replaces had none, so it must live here. */
|
bars it replaces had none, so it must live here. */
|
||||||
.fc-chrome-continues {
|
.fc-chrome-continues {
|
||||||
|
/* Continues the nav's fade: HOLDS near the seam alpha through the first ~55%
|
||||||
|
(subtle), then eases down to transparent over the last ~45% with an
|
||||||
|
intermediate stop so the tail is soft — no hard line at the bottom edge
|
||||||
|
(operator 2026-07-13). Percentage stops keep the shape spanning the
|
||||||
|
element's height (survives the filter bar's expanding refine panel). */
|
||||||
background: linear-gradient(
|
background: linear-gradient(
|
||||||
to bottom,
|
to bottom,
|
||||||
rgba(var(--fc-chrome-rgb), var(--fc-chrome-seam)) 0%,
|
rgba(var(--fc-chrome-rgb), var(--fc-chrome-seam)) 0%,
|
||||||
|
rgba(var(--fc-chrome-rgb), 0.60) 55%,
|
||||||
|
rgba(var(--fc-chrome-rgb), 0.28) 82%,
|
||||||
rgba(var(--fc-chrome-rgb), 0) 100%
|
rgba(var(--fc-chrome-rgb), 0) 100%
|
||||||
);
|
);
|
||||||
backdrop-filter: blur(2px);
|
backdrop-filter: blur(2px);
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
"""Unit tests for ExtensionService._derive — the URL → (platform, slug)
|
||||||
|
parser that gates the browser extension's "Add as source" button and pulls
|
||||||
|
the creator slug on probe/add.
|
||||||
|
|
||||||
|
Regression cover for #1485: Patreon serves the same creator under three URL
|
||||||
|
shapes — bare `patreon.com/Atole`, `c/`, and `cw/` (the "creator workspace"
|
||||||
|
URL you land on once SUBSCRIBED). The button used to vanish while subscribed
|
||||||
|
because the pattern only matched the bare root and excluded `c/`.
|
||||||
|
|
||||||
|
_derive is pure URL parsing (no DB / no async), so a session-less instance is
|
||||||
|
fine to exercise directly.
|
||||||
|
"""
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
from backend.app.services.extension_service import (
|
||||||
|
ExtensionService,
|
||||||
|
InvalidUrlError,
|
||||||
|
UnknownPlatformError,
|
||||||
|
)
|
||||||
|
|
||||||
|
_svc = ExtensionService(None)
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"url, slug",
|
||||||
|
[
|
||||||
|
# All three Patreon creator prefixes resolve to the same vanity slug.
|
||||||
|
("https://www.patreon.com/Atole", "Atole"),
|
||||||
|
("https://www.patreon.com/c/Atole", "Atole"),
|
||||||
|
("https://www.patreon.com/cw/Atole", "Atole"), # subscribed-view URL
|
||||||
|
# A creator's inner page still derives the slug (trailing sub-path).
|
||||||
|
("https://www.patreon.com/cw/Atole/posts", "Atole"),
|
||||||
|
("https://www.patreon.com/Atole/membership", "Atole"),
|
||||||
|
("https://patreon.com/c/Atole", "Atole"), # bare host, no www
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_derive_patreon_creator_urls(url, slug):
|
||||||
|
platform, got = _svc._derive(url)
|
||||||
|
assert platform == "patreon"
|
||||||
|
assert got == slug
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize(
|
||||||
|
"url",
|
||||||
|
[
|
||||||
|
# Patreon's own nav pages must never read as a creator slug.
|
||||||
|
"https://www.patreon.com/home",
|
||||||
|
"https://www.patreon.com/settings",
|
||||||
|
"https://www.patreon.com/search",
|
||||||
|
"https://www.patreon.com/messages",
|
||||||
|
"https://www.patreon.com/library",
|
||||||
|
"https://www.patreon.com/notifications",
|
||||||
|
"https://www.patreon.com/posts/12345", # post permalink
|
||||||
|
"https://www.patreon.com/settings/billing", # nav sub-page
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_derive_patreon_nav_pages_rejected(url):
|
||||||
|
with pytest.raises(UnknownPlatformError):
|
||||||
|
_svc._derive(url)
|
||||||
|
|
||||||
|
|
||||||
|
def test_derive_rejects_missing_scheme():
|
||||||
|
with pytest.raises(InvalidUrlError):
|
||||||
|
_svc._derive("patreon.com/Atole")
|
||||||
Reference in New Issue
Block a user