Duolingo Streak Buff

Automatically buffs your streak on Duolingo.

// ==UserScript==
// @name         Duolingo Streak Buff
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Automatically buffs your streak on Duolingo.
// @author       Your Name
// @match        https://www.duolingo.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    const API_ENDPOINT = 'https://www.duolingo.com/2017-06-30/users/USERNAME/streak';
    const BUFF_STREAK = 365;

    async function buffStreak() {
        const response = await fetch(API_ENDPOINT, {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${localStorage.getItem('jwtToken')}`
            },
            body: JSON.stringify({ streak: BUFF_STREAK })
        });

        if (response.ok) {
            console.log(`Streak successfully buffed to ${BUFF_STREAK} days!`);
        } else {
            console.error('Failed to buff streak:', response.statusText);
        }
    }

    if (window.location.href.includes('duolingo.com')) {
        buffStreak();
    }
})();