Duolingo Streak Saver

Tự động duy trì streak hàng ngày trên Duolingo

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Duolingo Streak Saver
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Tự động duy trì streak hàng ngày trên Duolingo
// @author       Bạn
// @match        https://www.duolingo.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const saveStreak = async () => {
        const response = await fetch('https://www.duolingo.com/2017-06-30/users/{user_id}/xp', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${localStorage.getItem('jwt')}`
            },
            body: JSON.stringify({
                'xpGained': 10,
                'learningLanguage': 'en'
            })
        });

        if (response.ok) {
            console.log('Streak saved successfully!');
        } else {
            console.error('Failed to save streak.');
        }
    };

    const runStreakSaver = () => {
        if (window.location.href.includes('duolingo.com')) {
            saveStreak();
        }
    };

    setInterval(runStreakSaver, 3600000); // Tự động gọi mỗi giờ
})();