diff --git a/src/app/content.ts b/src/app/content.ts index f582ad0..9ae1527 100644 --- a/src/app/content.ts +++ b/src/app/content.ts @@ -1,14 +1,10 @@ -import {getState, StateType} from './state/get-state'; +import {getState} from './state/get-state'; import {initializeState} from './state/initialize-state'; import {setState, StateKeys} from './state/set-state'; import {Ad} from './ad/ad'; +import {addContentButton} from './utils/add-content-button'; -/** - * Content script entry point. - * - * @returns {Promise} - The state of the extension. - */ -export async function content(): Promise { +export async function content(): Promise { await initializeState(); const state = await getState(); @@ -22,7 +18,7 @@ export async function content(): Promise { } } - return state; + addContentButton(); } window.addEventListener('load', content); diff --git a/src/app/utils/add-content-button.ts b/src/app/utils/add-content-button.ts new file mode 100644 index 0000000..89b5e37 --- /dev/null +++ b/src/app/utils/add-content-button.ts @@ -0,0 +1,16 @@ +import {StateKeys, setState} from '../state/set-state'; + +export function addContentButton() { + const container = document.querySelector('.mt-xl'); + const button = document.createElement('button'); + button.id = 'export'; + button.textContent = 'Export PDF'; + button.className = + 'u-shadow-border-transition box-border inline-flex items-center justify-center gap-md whitespace-nowrap px-lg text-body-1 font-bold focus-visible:outline-none focus-visible:u-ring [&:not(:focus-visible)]:ring-inset bg-transparent border-sm border-current min-w-sz-44 h-sz-44 rounded-lg hover:bg-support/dim-5 enabled:active:bg-support/dim-5 focus-visible:bg-support/dim-5 text-support w-full'; + + button.onclick = async () => { + await setState(StateKeys.isTriggered, true); + }; + + container.appendChild(button); +}