Skip to content

Instantly share code, notes, and snippets.

View Elvincth's full-sized avatar
🚀
Hey

Elvin Chu Elvincth

🚀
Hey
View GitHub Profile
@Elvincth
Elvincth / gist:7a891fb67b09c03b7e654497bb6bb6c5
Created May 29, 2025 15:49
Auto click copilot "Contiue" button
// Function to find and click the Continue button with exact text
function clickContinueButton() {
const continueButton = Array.from(
document.querySelectorAll('a.monaco-button.monaco-text-button[role="button"]')
).find(button => button.textContent.trim() === 'Continue');
if (continueButton) {
continueButton.click();
console.log('Continue button clicked');
}
@Elvincth
Elvincth / useBeforeUnload.ts
Created May 8, 2024 10:04
Add the "Changes you made may not be saved" warning to a Next.js app
import { Router } from "next/router";
import { useCallback, useEffect } from "react";
export const useBeforeUnload = (
enabled: boolean | (() => boolean) = true,
message = "Changes you made may not be saved.",
) => {
const handler = useCallback(
(event: BeforeUnloadEvent) => {
const finalEnabled = typeof enabled === "function" ? enabled() : true;
@Elvincth
Elvincth / test.model.ts
Created August 22, 2022 10:22
mongoose-paginate-v2 typescript usage
schema.plugin(paginate);
export const CourseModel: PaginateModel<ICourse> =
(models.Course as PaginateModel<ICourse>) ||
model<ICourse, PaginateModel<ICourse>>("Course", schema);