Greasy Fork

Greasy Fork is available in English.

Bunpro Study Streak 2 Dragon

Study streaks can be stressful or demoralizing, so we'll replace them with dragons instead 🐉 ...Or whatever you prefer.

当前为 2023-08-11 提交的版本,查看 最新版本

// ==UserScript==
// @name         Bunpro Study Streak 2 Dragon
// @namespace    http://tampermonkey.net/
// @version      1b
// @description  Study streaks can be stressful or demoralizing, so we'll replace them with dragons instead 🐉 ...Or whatever you prefer.
// @author       Humin
// @match        https://bunpro.jp/dashboard
// @match        https://bunpro.jp/user/profile
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    //Edit the below to change the text that says "Study Streak".
    const newDescriptor = 'Dragon Status';
    //Edit the below to change the study streak number to something else. Also this will be static.
    const newText = '🐉';

    (new MutationObserver(check)).observe(document, {childList: true, subtree: true});

    function check(changes, observer) { //Because Bunpro likes to do a lot of dynamic loading and these can be some of the last to load.
        if (document.querySelector('li.grid:nth-child(2) > p:nth-child(2)') && document.querySelector('li.grid:nth-child(2) > h4:nth-child(1)')){
            observer.disconnect();
            const studyStreakDashboardText = document.querySelector('li.grid:nth-child(2) > h4:nth-child(1)');
            const studyStreakDashboardNumber = document.querySelector('li.grid:nth-child(2) > p:nth-child(2)');
            studyStreakDashboardText.innerHTML = newDescriptor;
            studyStreakDashboardNumber.innerHTML = newText;
        }
        else if (document.querySelector('div.user-profile--stats-border:nth-child(2) > p:nth-child(1)') && document.querySelector('div.user-profile--stats-border:nth-child(2) > span:nth-child(2)')){
            observer.disconnect();
            const studyStreakProfileText = document.querySelector('div.user-profile--stats-border:nth-child(2) > p:nth-child(1)');
            const studyStreakProfileNumber = document.querySelector('div.user-profile--stats-border:nth-child(2) > span:nth-child(2)');
            studyStreakProfileText.innerHTML = newDescriptor;
            studyStreakProfileNumber.innerHTML = newText;
        }
    }
})();