diff --git a/src/entries/background/main.ts b/src/entries/background/main.ts index d89642e..08909c2 100644 --- a/src/entries/background/main.ts +++ b/src/entries/background/main.ts @@ -68,7 +68,7 @@ browser.runtime.onConnect.addListener((port) => { return await response.json(); } } - })().then((r) => port.postMessage({ id: parsed.id, content: r })); + })().then((r) => port.postMessage({ id: parsed.id, uuid: parsed.uuid, content: r })); }); }); diff --git a/src/entries/contentScript/api.ts b/src/entries/contentScript/api.ts new file mode 100644 index 0000000..9d899a3 --- /dev/null +++ b/src/entries/contentScript/api.ts @@ -0,0 +1,14 @@ +import { JsonRequest, sendMessage } from '~/lib/messages'; + +export async function anilistApiRequest(query: string): Promise { + return await sendMessage(JsonRequest, { + url: 'https://graphql.anilist.co', + init: { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ query: query }) + } + }); +} diff --git a/src/entries/contentScript/render.ts b/src/entries/contentScript/render.ts index e92bb13..e8ed78a 100644 --- a/src/entries/contentScript/render.ts +++ b/src/entries/contentScript/render.ts @@ -11,6 +11,7 @@ export async function render( mode: import.meta.env.MODE === 'development' ? 'open' : 'closed' }); const appRoot = document.createElement('div'); + appRoot.style.display = 'unset'; if (import.meta.hot) { const { addViteStyleTarget } = await import('@samrum/vite-plugin-web-extension/client'); @@ -36,9 +37,15 @@ export async function render( export class MountComponent { static elems: Map = new Map(); - static mount(component: typeof SvelteComponent, cssPaths: string[], target: HTMLElement) { + static mount( + component: typeof SvelteComponent, + cssPaths: string[], + target: HTMLElement, + props?: Record + ) { render(cssPaths, target, (app) => { new component({ + props: props, target: app }); }).then((e) => this.elems.set(component.name, e)); diff --git a/src/entries/contentScript/website/series/elements/AnimeListLinks.svelte b/src/entries/contentScript/website/series/elements/AnimeListLinks.svelte new file mode 100644 index 0000000..c62dab0 --- /dev/null +++ b/src/entries/contentScript/website/series/elements/AnimeListLinks.svelte @@ -0,0 +1,75 @@ + + +
+ {#if anilist && anilistId} + + + + {/if} + {#if mal && malId} + + + + {/if} +
+ + diff --git a/src/entries/contentScript/website/series/elements/NextEpisodeAirDate.svelte b/src/entries/contentScript/website/series/elements/NextEpisodeAirDate.svelte index 529c9f8..8f4f548 100644 --- a/src/entries/contentScript/website/series/elements/NextEpisodeAirDate.svelte +++ b/src/entries/contentScript/website/series/elements/NextEpisodeAirDate.svelte @@ -1,33 +1,24 @@