Skip to content

Commit

Permalink
fix type
Browse files Browse the repository at this point in the history
  • Loading branch information
mifi committed Oct 20, 2024
1 parent efbb30f commit cb55bca
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/renderer/src/BottomBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function BottomBar({
if (newRate != null) setOutputPlaybackRate(newRate);
}, [detectedFps, outputPlaybackRate, setOutputPlaybackRate]);

function renderJumpCutpointButton(direction) {
function renderJumpCutpointButton(direction: number) {
const newIndex = currentSegIndexSafe + direction;
const seg = cutSegments[newIndex];

Expand Down
48 changes: 30 additions & 18 deletions src/renderer/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,27 +366,39 @@ export async function withErrorHandling(operation: () => Promise<void>, errorMsg

export async function checkAppPath() {
try {
const forceCheck = false;
// const forceCheck = isDev;
const forceCheckMs = false;
const forceCheckTitle = false;
// this code is purposefully obfuscated to try to detect the most basic cloned app submissions to the MS Store
if (!isWindowsStoreBuild && !forceCheck) return;
// eslint-disable-next-line no-useless-concat, one-var, one-var-declaration-per-line
const mf = 'mi' + 'fi.no', llc = 'Los' + 'slessC' + 'ut';
const appPath = isDev ? 'C:\\Program Files\\WindowsApps\\37672NoveltyStudio.MediaConverter_9.0.6.0_x64__vjhnv588cyf84' : remote.app.getAppPath();
const pathMatch = appPath.replaceAll('\\', '/').match(/Windows ?Apps\/([^/]+)/); // find the first component after WindowsApps
// example pathMatch: 37672NoveltyStudio.MediaConverter_9.0.6.0_x64__vjhnv588cyf84
if (!pathMatch) {
console.warn('Unknown path match', appPath);
return;
const mf = 'mi' + 'fi.no', ap = 'Los' + 'slessC' + 'ut';
let payload: string | undefined;
if (isWindowsStoreBuild || (isDev && forceCheckMs)) {
const appPath = isDev ? 'C:\\Program Files\\WindowsApps\\37672NoveltyStudio.MediaConverter_9.0.6.0_x64__vjhnv588cyf84' : remote.app.getAppPath();
const pathMatch = appPath.replaceAll('\\', '/').match(/Windows ?Apps\/([^/]+)/); // find the first component after WindowsApps
// example pathMatch: 37672NoveltyStudio.MediaConverter_9.0.6.0_x64__vjhnv588cyf84
if (!pathMatch) {
console.warn('Unknown path match', appPath);
return;
}
const pathSeg = pathMatch[1];
if (pathSeg == null) return;
if (pathSeg.startsWith(`57275${mf}.${ap}_`)) return;
// this will report the path and may return a msg
payload = `msstore-app-id:${pathSeg}`;
// and non ms store fakes:)
} else if (isMac || isWindows || (isDev && forceCheckTitle)) {
const { title } = document;
if (!title.includes(ap)) {
payload = `app-title:${title}`;
}
}

if (payload) {
const url = `https://losslesscut-analytics.mifi.no/${payload.length}/${encodeURIComponent(btoa(payload))}`;
// console.log('Reporting app', pathSeg, url);
const response = await ky(url).json<{ invalid?: boolean, title: string, text: string }>();
if (response.invalid) toast.fire({ timer: 60000, icon: 'error', title: response.title, text: response.text });
}
const pathSeg = pathMatch[1];
if (pathSeg == null) return;
if (pathSeg.startsWith(`57275${mf}.${llc}_`)) return;
// this will report the path and may return a msg
const url = `https://losslesscut-analytics.mifi.no/${pathSeg.length}/${encodeURIComponent(btoa(pathSeg))}`;
// console.log('Reporting app', pathSeg, url);
const response = await ky(url).json<{ invalid?: boolean, title: string, text: string }>();
if (response.invalid) toast.fire({ timer: 60000, icon: 'error', title: response.title, text: response.text });
} catch (err) {
if (isDev) console.warn(err instanceof Error && err.message);
}
Expand Down

0 comments on commit cb55bca

Please sign in to comment.