Code Monkey home page Code Monkey logo

haha-funny-leetcode-extension's People

Contributors

bukomp avatar dependabot[bot] avatar erik-mckelvey avatar green1490 avatar harsh11101 avatar kmooredev avatar mgel avatar qlwentt avatar sanjai0py avatar tannnxr avatar tayomide avatar the-codingsloth avatar wllfaria avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

haha-funny-leetcode-extension's Issues

A way to handle premium problems

need a way to filter out premium problems for people who don't have LeetCode premium

  1. Might have to edit web scraper to check if it's premium (might also change JSON file format to include if isPremium)

Bug: userJustSubmitted race condition

The timeout in the onMessageReceived function in backjground.js introduces a race condition if the user hits submit more than once within 30 seconds:

case 'userClickedSubmit':
  userJustSubmitted = true;
  setTimeout(() => {
    userJustSubmitted = false;
  }, 30000); // Reset after 30 seconds
  break;

I can fix it

Modify the generateRandomLeetCodeProblem function to reduce the chance of an already solved problem

Modify this function to take into account the user's already solved problem (not sure based on solved extension problems or leetcode submissions)
From then make a randomize system to lower the chance to get the same problem.
Edge case:
If by some miracle they get the same problem they solved yesterday, change the problem (might need to have a previousProblem in the storage for this, just to make it easy)
If you guys have any other suggestions/ideas put a comment here

Critical Websites

What if we add a feature that enables users to add websites that are absolutely essential to them(like a school website) and prevent redirecting if there's a URL match

problem categories

let the user decide what problem category they'd like to work on like arrays, strings, linked lists, graphs, etc

Daily Streak Feature

Add a streak feature, which every we keep track of the consecutive days a user solves a leetcode problem.
example: User solves a problem for a whole week, their streak is 7.
User solves a problem today, their streak starts at 1.

Fix these stupid web scraper tests

Currently these tests pass when you run it individually, but if you run them together whether with jest or jest --runInBand the saveToJSON tests break (no clue why right now, probably doing some dumb mistake with the saving to file tests)

Firefox permissions being annoying

For the Firefox version, in order to get the extension to work, users have to manually enable optional permissions (really annoying). It's not automatic like chrome. If anyone can figure out a way to make it automatic, it would essentially complete the Firefox version.

Exploit: Submit an easy problem that you've solved already

A few problems with the current system:

  • The extension doesn't care what problem you solve, as long as you submit something successfully. That means I can navigate to an easy problem and submit the solution.
  • Even worse, it doesn't check if you've solved the given problem already. In that case you can just resubmit the solution saved by LC and you're done.

Potential Solutions

  • Make sure the submission-checker takes into account the problem statement
  • Use the publicly available, free-to-use LeetCode API's to go through all of the user's submissions and make sure your random problem isn't in those already. We can easily assume the list of the user's solved problems is <= 1,000,000 XD

Feature to set amount of problems to solve before removing redirect

Saw a YouTube comment of this cool (painful) feature, where instead of users only having to solve 1 problem, they can decide how many problems they want to solve before being able to access websites again.

  1. Can set it to 1 problem by default, and then letting the user decide from there.
  2. A way to handle this decision on the popup.js/popup.html (input, dropdown, etc)

Unable to login to leetcode if you have the extension active and you're signed out

The redirect rule is executing based on if the url contains "leetcode.com", if it doesn't then it'll redirect.
The problem is if the user tries to login with a provider such as google, github, etc they get redirect to accounts.google.com, github.com, so they can't sign in since they get redirected.
Need to update the rule to allow certain login provider urls to allow users to log in properly.

Extension tests

There's no tests for the extension, which makes it annoying to check some features, here's some test's I've thought of so far:

  1. Test the redirect rule if the user hasn't solved the problem
  2. Test the chrome.webRequest.onCompleted listener to test if the extension knows when the user solves the problem.
  3. Test the redirect rule if the user has solved the problem.
  4. Test the alarm listener to make sure it's updating the problem
  5. Test if the popup contains the correct information about the problem.
  6. Test the popup before they solve it and after they solve it.
  7. Test for situations where if the user turns off the extension, or service worker is inactive that their state is the same.
  8. Test if storage is working correctly
  9. Test that users can't exploit their submission by reusing an old submission, or is on a different problem

A feature to allow users to "give up" and search for solutions

Have a button either in the popup or in the leetcode website itself through the content script to allow users to "give up" which will give them access to websites like google (chatGPT? idk) and any other coding websites for help.
Still restrict them from websites like youtube, tiktok, twitter, facebook, instagram, etc. We're not that generous

Webscraper improvements

Please I beg of you to learn proper scraping before you decide to use an entire fucking browser (via puppeteer/selenium) for a super simple task.

What you did is the equivalent of bringing a rocket launcher to a knife fight

Here is a simpler solution:

image

image

(instead of evaling you would want to replace !0 with true and such, and use JSON.parse)

Redo alarm for new leetcode problem (whoops)

Saw a comment on YouTube where someone's leetcode problem changed mid day lol.
Currently I have the leetcode problem to change every 24 hours but based on the moment you installed the extension, not based on if it hits midnight.
Also need it to support time zones based on the user's location.

Temporary Disable button

add a disable button for users (people who hate torture). This button should simply remove all listeners and redirect rules happening in background.ts. Only thing that should probably stay active is probably the alarms (not sure though)

Better Error handling/messages

I'd appreciate if anyone would add better error handling for some of these functions, since it seems that these errors end up being really broad sometimes. ex of error handling: Error generating problem, Error handling submission, Error updating storage, etc.

Keep track of problems user solved

Add a feature to keep track of the problems the user has solved.
So it would show in the popup something along the lines of 30/75 problems solved if they're on blind75,
Would also be nice to also modify the content.js file to display a progress bar when they solve the problem giving them a signal that they're making progress.

Add pnpm to npm package

Upon installing this project, for me it was easier to have the pnpm package installed with npm. It shouldn't really effect anything,

Failed to fetch request.

Describe the bug

Because of a resource typo in the generateRandomLeetCodeProblem function it fails to fetch the app's resource in the background.js file and throws an exception.

To Reproduce

  • Install the dist

Expected behavior

To fetch "leetcode-problems/blind75Problems.json"

Screenshots/Video

image

Desktop

  • OS: Pop-os
  • Browser: Brave

Cool feature, solves a lot of problems!

I just found out about leetcode's list

What's cool about this is we could make our own list and make it public!

We could then use the GraphQL API request to get those lists. We could even create a list based on Neetcode's problems and add that to our dropdown or create our own list and add it to the category; we could create a list of only problems with linked lists!

I think it's worth looking into if it works, I'm making a PR soon with the current public lists and one of mine. If it works on everyone else's end, this could solve a lot of problems

Does not check off problems on Opera GX

The extension is cool, but after I have completed the problem on my browser Opera GX, it is not marked as completed by the extension, so I will be stuck inside Leetcode forever despite having successfully tortured myself :0

The feature to select from JSON files (select which problem sets you want)

By default right now, the extension is using the Blind 75 problem set since that JSON file is hard coded in.
Need to modify it to let users pick which problem sets they want.
Some things to think about:

  1. When the user installs the extension, do they have to select their problem set first or just give them a randomly problem and then decide?
  2. Allow the user to change their problem set before the 24 hours are up or allow them to change it, and it will apply tomorrow?

Option to load next problem from NeetCode problem tree

Add an option to load the next problem to solve, according to NeetCode's roadmap rather than a random problem from the tree.

Check out NeetCode's video on creating the NeetCode website. He explains how solving problems at random isn't the best approach and he created a tree we could use to determine the problem to solve.

image

Make The Readme More Attaractive

I think we can improve the readme file a bit more good So that the contributers have Completely understand this project.

PS: I would like to work on this issue :)

the redirect rule does not work on firefox

Was working on trying to get it to work on firefox, and have this issue:

async function setRedirectRule(newRedirectUrl: string) {
  let newRedirectRule = {
    id: RULE_ID,
    priority: 1,
    action: {
      type: "redirect",
      redirect: { url: newRedirectUrl }
    },
    condition: {
      urlFilter: "*://*/*",
      excludedInitiatorDomains: [
        "leetcode.com",
        "www.leetcode.com",
        "developer.chrome.com"
      ],

      resourceTypes: ["main_frame"]
    }
  }

  try {
    chrome.declarativeNetRequest.updateDynamicRules({
      removeRuleIds: [RULE_ID],
      addRules: [newRedirectRule]
    })
    const currentRules = await chrome.declarativeNetRequest.getDynamicRules()
    console.log("Redirect rule updated")
    console.log("Current rules:", currentRules)
  } catch (error) {
    console.error("Error updating redirect rule:", error)
  }
}

For some reason the new rule gets updated in chrome, but not in firefox. When I console log currentRules it shows an empty array on firefox, when it should be showing the rule inside of the array. If anyone knows why or can fix this, that'd be awesome and you're better than me

When changing difficulties, store those problems.

Currently every time you switch difficulties you change the assigned problem. That's cheating the system of torture.

  1. Whenever the user changes difficulty store those problems into storage so it would be "assigned-easy-problem", "assigned-medium-problem", "assigned-hard-problem"
  2. Whenever we do updateStorage, we should check if there's already an assigned problem. If there isn't then we can generate a new one, but if there is use the one in storage.

Manifest auto injecting CSP

I am trying to install the extension on firefox, when I do I get met with error
Warning details Reading manifest: Error processing content_security_policy.extension_pages: “script-src” directive contains a forbidden http: protocol source

I have found that in the manifest it is auto injecting
"content_security_policy": { "extension_pages": "script-src 'self' http://localhost;object-src 'self';" }

In version 3 of the manifest, you cannot refrence a remote script with script-src anymore, moreover it also does not allow http requests. I cannot find out why this is happening. I can only figure out that this is being injected on compile.

I discovered this while looking for the issues for #67

If you go to the compiled manifest in build/firefox and edit the manifest and CSP by removing the locahost injection is starts working. I do not know firefox well enough to figure this out right now.

Set time for extension to turn on at?

It would be nice to be able to set which time websites get blocked at. That way if I'm doing something important early in the morning I'm not blocked off from that and only get restricted during my free time or something . It would be nice to have a "turn on at [time]" option that you can set.

someone to go full genius and get this to support firefox

Yeah I need someone to help get this extension to function correctly on firefox. I've been trying but I think i'm too dumb.
What I've seen so far:

  1. Redirecting is not working (declartiveNetRequest issue) even though the rule is being applied.
  2. The listeners don't seem to be working either (runtime.onMessage and webRequest.onCompleted)
    If anyone can fix this I'd appreciate it so much lol
    I'd like to keep using this framework, since it feels really convenient. But if you can get this working by reverting back to no framework, we can work with it at least.

To get this working on firefox do these steps:
Add modify the manifest part of package.json to this:

"manifest": {
    "browser_specific_settings": {
      "gecko": {
        "id": "{743ff2c1-74c2-4384-a218-2c33d6a765a5}"
      }
    },
    "permissions": [
      "declarativeNetRequest",
      "declarativeNetRequestFeedback",
      "storage",
      "tabs",
      "activeTab",
      "alarms",
      "webRequest",
      "declarativeNetRequestWithHostAccess"
    ],
    "web_accessible_resources": [
      {
        "resources": [
          "leetcode-problems/*"
        ],
        "matches": [
          "https://www.plasmo.com/*"
        ]
      }
    ],
    "host_permissions": [
      "https://*/*"
    ]
  }

In your firefox browser type in for the url: about:debugging
Click the "This Firefox" button
You'll see the temporary extension area.
Now in the code in your terminal run "pnpm run dev --target=firefox-mv3"
You'll see a build folder with a folder called "firefox-mv3-dev"
In your Firefox browser click "Load Temporary Add-on" and select any file from the firefox-mv3-dev
The extension should be applied.

Interface with Leetcode API

From what I've seen so far, a lot of the issues here, like these

#33
#29
#20
#4
#2

could be fixed by using an API instead of a web scraper. Leetcode has a public graphql endpoint but there is no official documentation on how to use it, however there are open source APIs that people have put together. I'm currently looking into a few different APIs to see if I can connect the extension directly to LC's data for problems and user submissions.

https://github.com/codingsnack/leetcode-api/
https://github.com/JacobLinCool/LeetCode-Query

A timer to simulate interviews

Add a timer feature for user's to see how long it took them to solve a problem, and show them the recommend time to solve during an interview.
Timer depends on the problem:

  1. Easy problems: 10-15 minutes
  2. Medium problems: 25-30 minutes
  3. Hard problems: 45- 1 hour
    (not sure if these times are accurate, but from my experience it's what it feels like) you guys can help decide these timers.

Add TypeScript support

Currently using JavaScript throughout this whole extension and that's some Junior Developer behavior. TypeScript support would help a lot and make this look more professional because we're all 10x developers here.

Here's a link for chrome type package to get started:
chrome type package

Allow users to select difficulty of problem

Create the functionality of letting users to pick out difficulty of leetcode problems, so in the extension they have the option to only select easy, medium, hard problems, and an any difficulty option.

  1. Might have to modify the web scraper to scrape the difficulty of problems as well.
  2. Modify JSON file format to now include difficulty.
  3. Modify the popup to have something to let users select difficulty.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.