loveshdongre / leetcode-enhancer

A cross-browser extension to improve productivity on Leetcode
https://chrome.google.com/webstore/detail/leetcode-enhancer/gcmncppaaebldbkgkcbojghpmpjkdlmp
45 stars 5 forks source link

Intercepting Leetcode HTTP/XHR requests to delete data that the user doesn't want #2

Closed himittal09 closed 3 years ago

himittal09 commented 3 years ago

Instead of hiding the elements from the DOM with a CSS class, the request's response can be intercepted before it reaches to the leetcode client, and then we can delete entries for question which are premium only.

Leetcode API request URL to backend: "https://leetcode.com/api/problems/algorithms/"

Example Response: "stat_status_pairs": [ { "stat": { "question_id": 2062, "question__article__live": null, "question__article__slug": null, "question__article__has_video_solution": null, "question__title": "Game of Nim", "question__title_slug": "game-of-nim", "question__hide": false, "total_acs": 94, "total_submitted": 145, "frontend_question_id": 1908, "is_new_question": true }, "status": null, "difficulty": { "level": 2 }, "paid_only": true, "is_favor": false, "frequency": 0, "progress": 0 } ]

We need to iterate the stat_status_pairs array to filter the questions which has paid_only turned to false.

I don't know how to intercept http requests though Edit: little search landed me here: https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/webRequest#modifying_responses

loveshdongre commented 3 years ago

Hi @himittal09 Intercepting requests for free problems can be done but it is going to take time to implement. Not sure If It will be implemented in the next release yet as the following things will take time

Thanks for the research work