Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions src/entrypoints/amenzb.content.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { defineContentScript } from 'wxt/sandbox';
import { Content } from '~/Content';

export default defineContentScript({
matches: ['*://*.amenzb.moe/*', '*://amenzb.moe/*'],

main(ctx) {
new AmenzbContent(ctx);
},
});

class AmenzbContent extends Content {

get id() {
return 'amenzb';
}

apiKey: string = '';

get isList(): boolean {
return document.querySelectorAll('a[href*="/download/"]').length > 1;
}

get isDetail(): boolean {
return window.location.pathname.startsWith('/release/');
}

// Fetches the API key from the profile page and caches it
async ready(): Promise<void> {
const res = await fetch('https://amenzb.moe/profile', { credentials: 'include' });
const html = await res.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, 'text/html');
const input = doc.getElementById('apiKeyInput') as HTMLInputElement;
if (input?.value) {
this.apiKey = input.value;
console.info(`[NZB Unity] ameNZB API key loaded`);
} else {
console.warn(`[NZB Unity] ameNZB API key not found — are you logged in?`);
}
}

// Converts a /download/123456 URL into the authenticated API URL
buildApiUrl(downloadUrl: string): string {
const id = downloadUrl.split('/download/')[1];
return `https://amenzb.moe/api?t=get&apikey=${this.apiKey}&id=${id}`;
}

initializeListLinks = () => {
const links = document.querySelectorAll('a[href*="/download/"]');
links.forEach(el => {
const anchor = el as HTMLAnchorElement;
this.createAddUrlLink({
url: this.buildApiUrl(anchor.href),
adjacent: anchor,
});
});
}

initializeDetailLinks = () => {
const anchor = document.querySelector('a[href*="/download/"]') as HTMLAnchorElement;
if (anchor) {
this.createAddUrlLink({
url: this.buildApiUrl(anchor.href),
adjacent: anchor,
});
}
}
}
28 changes: 28 additions & 0 deletions src/entrypoints/dognzb.content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,34 @@ class DognzbContent extends Content {
}

async ready() {
// Only apply CSS fix in Chrome — Firefox handles CSP differently and shows the icon fine
const isChrome = navigator.userAgent.includes('Chrome') && !navigator.userAgent.includes('Firefox');

if (isChrome) {
const style = document.createElement('style');
style.textContent = `
.NZBUnityLink {
background-image: none !important;
min-width: 16px !important;
border-radius: 2px !important;
background-color: #40a040 !important;
color: white !important;
font-size: 13px !important;
font-weight: bold !important;
text-align: center !important;
line-height: 16px !important;
text-decoration: none !important;
}
.NZBUnityLink::before {
content: '↓' !important;
}
.NZBUnityLink.pending { background-color: #808080 !important; }
.NZBUnityLink.success { background-color: #40a040 !important; }
.NZBUnityLink.error { background-color: #cc3333 !important; }
`;
document.head.appendChild(style);
}

this.observer = new MutationObserver((mutations) => {
console.info(`[NZB Unity] Content changed, updating links...`);
this.onReady(); // Re-run initialization
Expand Down
1 change: 1 addition & 0 deletions src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const DefaultDownloaderOptions: DownloaderOptions = {
export const DefaultIndexers: Record<string, IndexerOptions> = {
abnzb: { Display: 'abNZB', Enabled: true },
althub: { Display: 'altHUB', Enabled: true },
amenzb: { Display: 'ameNZB', Enabled: true },
animetosho: { Display: 'AnimeTosho', Enabled: true },
binsearch: { Display: 'BinSearch', Enabled: true },
dognzb: { Display: 'DogNZB', Enabled: true },
Expand Down