Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
blueagler authored Jun 15, 2023
1 parent cf34faf commit 2b42354
Show file tree
Hide file tree
Showing 26 changed files with 1,840 additions and 734 deletions.
9 changes: 5 additions & 4 deletions dist/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "DeepL Crack",
"version": "1.1.8",
"version": "1.2.3",
"description": "Unlock DeepL Pro features: character limit, document editing",
"manifest_version": 3,
"action": {},
"action": {
"default_popup": "popup.html"
},
"declarative_net_request": {
"rule_resources": [
{
Expand Down Expand Up @@ -38,8 +40,7 @@
],
"permissions": [
"declarativeNetRequest",
"cookies",
"webNavigation"
"cookies"
],
"host_permissions": [
"*://*.deepl.com/*"
Expand Down
2 changes: 1 addition & 1 deletion dist/redirect.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"action": {
"type": "redirect",
"redirect": {
"url": "https://serverless.blueagle.top/deepl-crack/get-client-state"
"url": "https://v1-cf-api.blueagle.top/deepl-crack/get-client-state"
}
},
"condition": {
Expand Down
54 changes: 30 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,50 @@
"name": "deepl-crack",
"license": "GPL-3.0",
"description": "A browser extension to crack DeepL's 5000 characters limit and unlock editing restrictions",
"version": "1.1.8",
"version": "1.2.3",
"scripts": {
"build": "rollup --config rollup.config.prod.mjs && rollup --config rollup.config.background.prod.mjs",
"dev": "rollup --config rollup.config.dev.mjs && rollup --config rollup.config.background.dev.mjs",
"validate": "deno run --allow-write --allow-read --allow-net ./deepl-api-validator.js"
"validate": "deno run --allow-write --allow-read --allow-net ./deepl-api-validator.ts"
},
"dependencies": {
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@mui/icons-material": "^5.10.16",
"@mui/material": "^5.10.17",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.11.16",
"@mui/material": "^5.13.5",
"@mui/x-data-grid-premium": "6.7.0",
"@mui/x-license-pro": "6.6.0",
"byte-guide": "^1.0.7",
"jszip": "^3.10.1",
"localforage": "^1.10.0",
"mobx": "^6.7.0",
"mobx-persist-store": "^1.1.2",
"mobx-react": "^7.6.0",
"notistack": "3.0.0-alpha.11",
"preact": "^10.11.3",
"pretty-bytes": "^6.0.0",
"mobx": "^6.9.0",
"mobx-persist-store": "^1.1.3",
"mobx-react": "^8.0.0",
"notistack": "3.0.1",
"preact": "^10.15.1",
"pretty-bytes": "^6.1.0",
"random-useragent": "0.5.0",
"react-transition-group": "^4.4.5"
"react": "18.2.0",
"react-dom": "18.2.0"
},
"devDependencies": {
"@babel/core": "7.20.7",
"@babel/preset-react": "^7.18.6",
"@emotion/babel-plugin": "^11.10.5",
"@rollup/plugin-alias": "4.0.2",
"@babel/core": "7.22.5",
"@babel/preset-react": "^7.22.5",
"@emotion/babel-plugin": "^11.11.0",
"@rollup/plugin-alias": "5.0.0",
"@rollup/plugin-babel": "^6.0.3",
"@rollup/plugin-commonjs": "23.0.4",
"@rollup/plugin-commonjs": "25.0.1",
"@rollup/plugin-json": "^6.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.1",
"@rollup/plugin-terser": "0.2.0",
"@types/babel__core": "^7.1.20",
"@rollup/plugin-node-resolve": "^15.1.0",
"@rollup/plugin-replace": "^5.0.2",
"@rollup/plugin-terser": "0.4.3",
"@types/babel__core": "^7.20.1",
"@types/random-useragent": "^0.3.1",
"@types/react": "^18.2.12",
"@types/react-dom": "^18.2.5",
"babel-plugin-transform-imports": "^2.0.0",
"esbuild": "^0.16.2",
"rollup": "3.7.1-0",
"esbuild": "^0.18.2",
"rollup": "3.25.1",
"rollup-plugin-esbuild": "^5.0.0",
"rollup-plugin-worker": "^3.0.4"
}
Expand Down
232 changes: 20 additions & 212 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,18 @@
import { memo, useEffect, useCallback, useState } from 'react'


import CookieIcon from '@mui/icons-material/Cookie';
import TipsAndUpdates from '@mui/icons-material/TipsAndUpdates';

import Document from 'components/document';
import Annoumcement from 'components/annoumcement';
import Btns from 'components/Btns';
import GlobalStyle from 'components/GlobalStyle';
import Token from 'components/token';
import Sponsor from 'components/Sponsor';

import store from 'store';
import { memo } from 'react'
import { createTheme, ThemeProvider } from '@mui/material/styles';
import { SnackbarProvider } from 'notistack';
import { LicenseInfo } from '@mui/x-license-pro';

import { useLocalObservable, Observer } from 'mobx-react';
import { SnackbarProvider, enqueueSnackbar } from 'notistack';
import { cleanCookies, waitForSelector, sendMessage } from "utils";
import api, { generateUpdateBtn } from "utils/api";
import FolderIcon from '@mui/icons-material/Folder';
import Loading from 'components/Loading';
import GlobalStyles from '@mui/material/GlobalStyles';
import DarkModeIcon from '@mui/icons-material/DarkMode';
import LightModeIcon from '@mui/icons-material/LightMode';
import { observe } from 'mobx';
import TokenIcon from '@mui/icons-material/Token';
import DocumentsManager from './components/DocumentsManager';
import Announcements from './components/Announcements';
import Banners from './components/Banners';
import GlobalStyle from './components/GlobalStyle';
import TokensAndCredentialsManager from './components/TokensAndCredentialsManager';
import Sponsor from './components/Sponsor';
import Loading from './components/Loading';
import Guide from './components/Guide';

import { proxy, unproxy } from "proxy";
LicenseInfo.setLicenseKey("63cdcff003c86a961f1b47b5703dd5e0Tz0wLEU9MjUzNDA0ODY0MDAwMDAwLFM9cHJlbWl1bSxMTT1zdWJzY3JpcHRpb24sS1Y9Mg==");

const theme = createTheme({
palette: {
Expand All @@ -45,196 +31,18 @@ const theme = createTheme({
}
});

const DarkModeStyle = <GlobalStyles
styles={{
'html': {
filter: 'invert(0.95) hue-rotate(180deg)',
}
}}
/>;

function handleDomModifier(domModifier) {
for (const { selector, enabled, type, options } of domModifier ?? []) {
if (enabled) {
const handler = {
replaceContent: (el, { html }) => {
el.innerHTML = html;
},
insertAdjacentHTML: (el, { html, location }) => {
el.insertAdjacentHTML(location, html);
},
remove: (el) => {
el.remove();
},
setAttribute: (el, { attr, value }) => {
el.setAttribute(attr, value);
}
}[type];
if (handler) {
(async function () {
handler(await waitForSelector(selector), options)
})()
}
}
}
}

async function getDomModifier() {
let domModifier = [];
if (Date.now() - store.cacheStore.getPersistCache('lastGetDomModifier') < 10800000) {
domModifier = store.configStore.getDomModifier;
} else {
try {
domModifier = await api.getDomModifier();
store.cacheStore.setPersistCache('lastGetDomModifier', Date.now());
} catch (error) {
domModifier = store.configStore.getDomModifier;
enqueueSnackbar(`Get dom modifier failed: ${error.message}`, { variant: 'error' })
}
}
handleDomModifier(domModifier);
}

async function checkUpdate() {
if (Date.now() - store.cacheStore.getPersistCache('lastUpdateCheck') < 300000) return;
try {
const update = await api.getUpdate();
if (update.available) {
enqueueSnackbar(`Update available: ${update.version}!`, { variant: 'info', action: () => generateUpdateBtn(update.url), })
}
store.cacheStore.setPersistCache('lastUpdateCheck', Date.now());
} catch (error) {
enqueueSnackbar(`Update check failed: ${error.message}`, { variant: 'error' })
}
}

async function loadRemoteScript() {
if (Date.now() - store.cacheStore.getPersistCache('lastGetRemoteScript') < 10800000) {
setTimeout(store.cacheStore.getPersistCache('remoteScript'), 0);
} else {
try {
const code = await sendMessage({
method: 'proxyFetch',
params: {
url: `${process.env.NODE_ENV === 'development' ? "http://127.0.0.1:3001" : "https://serverless.blueagle.top"}/static/deepl-crack/remote-script.js`,
config: {}
}
});
setTimeout(code, 0);
store.cacheStore.setPersistCache('lastGetRemoteScript', Date.now());
store.cacheStore.setPersistCache('remoteScript', code);
} catch (error) {
if (store.cacheStore.getPersistCache('remoteScript')) {
setTimeout(store.cacheStore.getPersistCache('remoteScript'), 0);
}
enqueueSnackbar(`Get remote script failed: ${error.message}`, { variant: 'error' })
}
}
}

function App() {

const [darkMode, setDarkMode] = useState(localStorage.getItem('darkMode') === 'true' ? true : false);

const configStore = useLocalObservable(() => store.configStore);
const tokenStore = useLocalObservable(() => store.tokenStore);

const handleToggleDocumentWindow = useCallback(() => store.windowStore.toggleDocumentWindow(), []);
const handleToggleAnnouncementWindow = useCallback(() => store.windowStore.toggleAnnouncementWindow(), []);
const handleToggleTokenWindow = useCallback(() => store.windowStore.toggleTokenWindow(), []);
const handleToggleDarkMode = useCallback(() => {
const value = !darkMode;
setDarkMode(value);
localStorage.setItem('darkMode', `${value}`);
}, [darkMode]);
const handleCleanCookies = useCallback(() => {
try {
cleanCookies()
} catch (error) {
enqueueSnackbar(error.message, { variant: 'error' })
}
}, []);

useEffect(() => {
const isHydratedListener = observe(configStore, 'isHydrated', ({ newValue }) => {
if (newValue) {
checkUpdate();
loadRemoteScript();
getDomModifier();
isHydratedListener();
}
});

const getAvailableListener = observe(configStore, 'getAvailable', ({ newValue }) => {
if (newValue) {
proxy();
} else {
unproxy()
}
});

const visibleListener = document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'visible') {
checkUpdate();
}
})

return () => {
getAvailableListener();
isHydratedListener();
document.removeEventListener('visibilitychange', visibleListener);
}
}, [])

export default memo(function () {
return (
<ThemeProvider theme={theme}>
{darkMode && DarkModeStyle}
<GlobalStyle />
<SnackbarProvider autoHideDuration={3000} maxSnack={6} />
<Loading />
<Observer>{() =>
<Btns
btns={[
{
label: 'Announcement',
icon: <TipsAndUpdates />,
onClick: handleToggleAnnouncementWindow,
show: (configStore.getAnnouncements ?? []).length > 0
},
{
label: 'Documents',
icon: <FolderIcon />,
onClick: handleToggleDocumentWindow,
show: true
},
{
label: tokenStore.getActiveToken ? tokenStore.getActiveToken?.type === 'pro-session' ? 'Using Pro Account Session' : 'Using DeepL Api Free Token' : 'Tokens',
icon: <TokenIcon />,
onClick: handleToggleTokenWindow,
bounce: Boolean(tokenStore.getActiveToken),
show: true
},
{
label: darkMode ? 'Light Mode' : 'Dark Mode',
icon: darkMode ? <LightModeIcon /> : <DarkModeIcon />,
onClick: handleToggleDarkMode,
show: true
},
{
label: 'Clean Cookies',
icon: <CookieIcon />,
onClick: handleCleanCookies,
show: true
}
]}
/>
}</Observer>
<Document />
<Annoumcement />
<Token />
<Sponsor />
<Loading />
<Banners />
<DocumentsManager />
<Announcements />
<TokensAndCredentialsManager />
<Guide />
</ThemeProvider>
)
}

export default memo(App, () => true);
}, () => true)
Loading

0 comments on commit 2b42354

Please sign in to comment.