mirror of https://github.com/sussy-code/smov.git
commit
147fad59e3
|
@ -32,6 +32,7 @@
|
||||||
"@formkit/auto-animate": "^0.8.2",
|
"@formkit/auto-animate": "^0.8.2",
|
||||||
"@headlessui/react": "^1.7.19",
|
"@headlessui/react": "^1.7.19",
|
||||||
"@ladjs/country-language": "^1.0.3",
|
"@ladjs/country-language": "^1.0.3",
|
||||||
|
"@marsidev/react-turnstile": "^0.7.1",
|
||||||
"@movie-web/providers": "github:sussy-code/providers",
|
"@movie-web/providers": "github:sussy-code/providers",
|
||||||
"@noble/hashes": "^1.4.0",
|
"@noble/hashes": "^1.4.0",
|
||||||
"@plasmohq/messaging": "^0.6.2",
|
"@plasmohq/messaging": "^0.6.2",
|
||||||
|
@ -66,7 +67,6 @@
|
||||||
"react-lazy-with-preload": "^2.2.1",
|
"react-lazy-with-preload": "^2.2.1",
|
||||||
"react-router-dom": "^6.23.0",
|
"react-router-dom": "^6.23.0",
|
||||||
"react-sticky-el": "^2.1.0",
|
"react-sticky-el": "^2.1.0",
|
||||||
"react-turnstile": "^1.1.3",
|
|
||||||
"react-use": "^17.5.0",
|
"react-use": "^17.5.0",
|
||||||
"semver": "^7.6.0",
|
"semver": "^7.6.0",
|
||||||
"slugify": "^1.6.6",
|
"slugify": "^1.6.6",
|
||||||
|
|
9501
pnpm-lock.yaml
9501
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
|
@ -176,7 +176,6 @@ const root = createRoot(container!);
|
||||||
root.render(
|
root.render(
|
||||||
<StrictMode>
|
<StrictMode>
|
||||||
<ErrorBoundary>
|
<ErrorBoundary>
|
||||||
<TurnstileProvider />
|
|
||||||
<HelmetProvider>
|
<HelmetProvider>
|
||||||
<Suspense fallback={<LoadingScreen type="lazy" />}>
|
<Suspense fallback={<LoadingScreen type="lazy" />}>
|
||||||
<ExtensionStatus />
|
<ExtensionStatus />
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
import { Turnstile } from "@marsidev/react-turnstile";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { useRef } from "react";
|
import { useRef } from "react";
|
||||||
import Turnstile, { BoundTurnstileObject } from "react-turnstile";
|
|
||||||
import { create } from "zustand";
|
import { create } from "zustand";
|
||||||
import { immer } from "zustand/middleware/immer";
|
import { immer } from "zustand/middleware/immer";
|
||||||
|
|
||||||
|
@ -10,16 +10,12 @@ import { conf } from "@/setup/config";
|
||||||
export interface TurnstileStore {
|
export interface TurnstileStore {
|
||||||
isInWidget: boolean;
|
isInWidget: boolean;
|
||||||
turnstiles: {
|
turnstiles: {
|
||||||
controls: BoundTurnstileObject;
|
controls: any;
|
||||||
isInPopout: boolean;
|
isInPopout: boolean;
|
||||||
id: string;
|
id: string;
|
||||||
}[];
|
}[];
|
||||||
cbs: ((token: string | null) => void)[];
|
cbs: ((token: string | null) => void)[];
|
||||||
setTurnstile(
|
setTurnstile(id: string, v: any, isInPopout: boolean): void;
|
||||||
id: string,
|
|
||||||
v: BoundTurnstileObject | null,
|
|
||||||
isInPopout: boolean,
|
|
||||||
): void;
|
|
||||||
getToken(): Promise<string>;
|
getToken(): Promise<string>;
|
||||||
processToken(token: string | null, widgetId: string): void;
|
processToken(token: string | null, widgetId: string): void;
|
||||||
}
|
}
|
||||||
|
@ -80,11 +76,6 @@ export function isTurnstileInitialized() {
|
||||||
export async function getTurnstileToken() {
|
export async function getTurnstileToken() {
|
||||||
const turnstile = getTurnstile();
|
const turnstile = getTurnstile();
|
||||||
try {
|
try {
|
||||||
// I hate turnstile
|
|
||||||
(window as any).turnstile.execute(
|
|
||||||
document.querySelector(`#${turnstile.id}`),
|
|
||||||
{},
|
|
||||||
);
|
|
||||||
const token = await useTurnstileStore.getState().getToken();
|
const token = await useTurnstileStore.getState().getToken();
|
||||||
reportCaptchaSolve(true);
|
reportCaptchaSolve(true);
|
||||||
return token;
|
return token;
|
||||||
|
@ -110,18 +101,21 @@ export function TurnstileProvider(props: {
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
<Turnstile
|
<Turnstile
|
||||||
sitekey={siteKey}
|
siteKey={siteKey}
|
||||||
theme="light"
|
options={{
|
||||||
onLoad={(widgetId, bound) => {
|
refreshExpired: "auto",
|
||||||
|
theme: "light",
|
||||||
|
}}
|
||||||
|
onWidgetLoad={(widgetId) => {
|
||||||
idRef.current = widgetId;
|
idRef.current = widgetId;
|
||||||
setTurnstile(widgetId, bound, !!props.isInPopout);
|
setTurnstile(widgetId, "sudo", !!props.isInPopout);
|
||||||
}}
|
}}
|
||||||
onError={() => {
|
onError={() => {
|
||||||
const id = idRef.current;
|
const id = idRef.current;
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
processToken(null, id);
|
processToken(null, id);
|
||||||
}}
|
}}
|
||||||
onVerify={(token) => {
|
onSuccess={(token) => {
|
||||||
const id = idRef.current;
|
const id = idRef.current;
|
||||||
if (!id) return;
|
if (!id) return;
|
||||||
processToken(token, id);
|
processToken(token, id);
|
||||||
|
@ -130,8 +124,6 @@ export function TurnstileProvider(props: {
|
||||||
onBeforeInteractive={() => {
|
onBeforeInteractive={() => {
|
||||||
props.onUpdateShow?.(true);
|
props.onUpdateShow?.(true);
|
||||||
}}
|
}}
|
||||||
refreshExpired="never"
|
|
||||||
execution="render"
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue