SweetCode is designed to make solving DSA problems easier and more accessible for everyone whether you're a fresher, a software engineer, or completely new to programming. In its current form as a Web Extension, SweetCode gamifies your DSA journey by blocking social media websites and rewards you with social media time as you solve problems. SweetCode also provides you AI-powered hints (at the cost of your accumulated social media time) whenever you get stuck.
New Feature: AI Hint Assistant - Get helpful hints for LeetCode problems in exchange for your earned social media time.
Future Development Plans: Support for GfG, Integration of Solution blogs. (New issues are always open, feel free to contribute!)
- Earn Rewards: Gain social media time based on LeetCode problem difficulty:
- Easy: 10 minutes.
- Medium: 20 minutes.
- Hard: 40 minutes.
- AI Hint Assistant: Get hints for LeetCode problems using AI (costs social media time):
- Ordinary Hint: 2 minutes.
- Advanced Hint: 3 minutes.
- Expert Hint: 5 minutes.
- Automatic Reset: Time allowance resets to zero every day.
- Controlled Access: Only allows access to social media websites when time is available.
- Customizable: Easily modify time rewards or add/remove social media platforms.
You can get started with SweetCode in two ways: either download the latest release directly or clone the repository from GitHub.
- Go to the Releases page on GitHub.
- Download the latest
.ziprelease package. - Extract the contents to a folder on your computer.
- Continue with the steps below to load the extension in your browser.
-
Clone this repository to your local machine:
git clone https://github.com/yourusername/sweetcode.git
-
Navigate to the project directory:
cd SweetCode
- Open your Chromium-based browser (Chrome, Edge, Brave, etc.) and navigate to Extensions.
- Enable Developer mode in the top-right corner.
- Click Load unpacked and select the directory where you cloned the repository.
- The extension will now appear in your extensions list.
To use the AI Hint Assistant feature, you'll need a Groq API key:
- Sign up for Groq: Visit Groq's website and create an account.
- Log in: Use your credentials to access the Groq console.
- Navigate to API Keys: Go to the API Keys section in your dashboard.
- Create a new key: Click "Create API Key" and give it a descriptive name.
- Copy your key: Save the generated API key securely - you'll need it for the extension.
- Click on the SweetCode extension icon in your browser toolbar.
- Click on the gear icon to open Settings.
- Enter your Groq API key in the "Groq API Key" field.
- Select your preferred AI model from the dropdown:
- Llama3.1-8b: Good balance of speed and quality.
- Kimi-k2: Fast and efficient for general hints.
- GPT-OSS-120b: Most advanced open source model for detailed hints.
- The extension will automatically save your settings.
- Navigate to any LeetCode problem page.
- Click the SweetCode extension icon to open the AI Assistant.
- Choose your hint level:
- Ordinary Hint: Basic guidance to get you started.
- Advanced Hint: More detailed approach suggestions.
- Expert Hint: Comprehensive strategy and insights.
- The AI will analyze the problem and provide a helpful hint.
- The corresponding time cost will be deducted from your social media allowance.
Note: The hint buttons only appear when you're on a LeetCode problem page. The AI analyzes the problem context automatically to provide relevant hints.
See the screenshots above for visual examples of the AI Assistant interface and hint system in action.
The extension now uses an improved helper function for better website management. To add or remove social media platforms:
- Open the
background.jsfile in a text editor. - Locate the
isSocialMediaMainPagefunction (around line 177). - The function now uses a more robust pattern-matching system with better URL parsing.
To add a new social media platform, follow this pattern:
// Add your pattern definition
const yourPlatformPattern = /^(www\.)?yourplatform\.com\/?.*/i;
// Add to the return statement
return (
// ... existing patterns ...
(urlObj.hostname === 'yourplatform.com' || urlObj.hostname === 'www.yourplatform.com') && yourPlatformPattern.test(urlObj.host + urlObj.pathname)
);Example: Adding LinkedIn support:
const linkedinPattern = /^(www\.)?linkedin\.com\/?.*/i;
return (
// ... existing patterns ...
(urlObj.hostname === 'linkedin.com' || urlObj.hostname === 'www.linkedin.com') && linkedinPattern.test(urlObj.host + urlObj.pathname)
);The helper function automatically excludes authentication pages, login forms, and other non-content pages to provide a better user experience.
- Open the
background.jsfile in a text editor. - Locate the
timeRewardsobject:const timeRewards = { 'Easy': 10, 'Medium': 20, 'Hard': 40 };
- Modify the values to set your desired reward times (in minutes). For example:
const timeRewards = { 'Easy': 5, 'Medium': 15, 'Hard': 30 };
- Save the file and reload the extension on the extensions page.
- Track LeetCode Submissions: The extension listens for LeetCode problem submissions. When you successfully submit a problem, it checks the difficulty level.
- Reward Social Media Time: Based on the problem difficulty, it adds the corresponding time to your social media allowance.
- AI Hint System: When you request a hint, the extension sends the problem context to Groq's AI API and deducts time from your allowance.
- Allow Social Media Access: If your time runs out, you can no longer access the pages of social media platforms (e.g., Instagram, YouTube, Facebook, Twitter/X). Other websites remain accessible as usual.
- Your social media time is tracked locally in your browser's storage and resets daily.
- The extension currently considers Instagram, YouTube, Facebook, Twitter/X, WebNovel, and NovelBin as social medias, with customization options to add others.
- The AI Hint Assistant requires an active internet connection and a valid Groq API key.
- Hint costs are deducted immediately when you request them, regardless of whether you use the hint or not.
Please go through CONTRIBUTING.md and follow the Code of Conduct



