IgnitiaPlus

Adds useful features to a study website, including element removal, clock, refresh warning, night mode, word counter, and focus timer with folding functionality.

// ==UserScript==
// @name         IgnitiaPlus
// @namespace    http://tampermonkey.net/
// @version      0.1.1
// @license      Apache-2.0
// @description  Adds useful features to a study website, including element removal, clock, refresh warning, night mode, word counter, and focus timer with folding functionality.
// @author       Minemetero
// @match        *://*.ignitiaschools.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=ignitiaschools.com
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    window.addEventListener('load', function() {
        // Remove unwanted elements
        var signOutElement = document.getElementById('logout');
        var bannerTabDivider = document.querySelectorAll('.bannerTabDivider');

        if (signOutElement) {
            signOutElement.remove();
        }

        bannerTabDivider.forEach(function(element) {
            element.remove();
        });

        // Add a clock to the bottom right corner
        var clock = document.createElement('div');
        clock.id = 'tampermonkey-clock';
        clock.style.position = 'fixed';
        clock.style.bottom = '10px';
        clock.style.right = '10px';
        clock.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
        clock.style.color = 'white';
        clock.style.padding = '5px 10px';
        clock.style.borderRadius = '5px';
        clock.style.fontFamily = 'Arial, sans-serif';
        clock.style.fontSize = '14px';
        clock.style.zIndex = '1000';

        function updateClock() {
            var now = new Date();
            var hours = now.getHours().toString().padStart(2, '0');
            var minutes = now.getMinutes().toString().padStart(2, '0');
            var seconds = now.getSeconds().toString().padStart(2, '0');
            clock.textContent = hours + ':' + minutes + ':' + seconds;
        }

        updateClock();
        setInterval(updateClock, 1000);
        document.body.appendChild(clock);

        // Add warning before refreshing or closing the page
        window.addEventListener('beforeunload', function (e) {
            var confirmationMessage = 'Are you sure you want to leave? Any unsaved changes will be lost.';
            e.preventDefault();
            e.returnValue = confirmationMessage;
            return confirmationMessage;
        });

        // Add Word Counter
        var wordCountContainer = document.createElement('div');
        wordCountContainer.id = 'word-count-container';
        wordCountContainer.style.position = 'fixed';
        wordCountContainer.style.bottom = '90px';
        wordCountContainer.style.right = '10px';
        wordCountContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
        wordCountContainer.style.color = 'white';
        wordCountContainer.style.padding = '5px 10px';
        wordCountContainer.style.borderRadius = '5px';
        wordCountContainer.style.fontFamily = 'Arial, sans-serif';
        wordCountContainer.style.fontSize = '14px';
        wordCountContainer.style.zIndex = '1000';
        wordCountContainer.style.cursor = 'pointer';

        var wordCountHeader = document.createElement('div');
        wordCountHeader.textContent = 'Word Count: 0 (Click to toggle)';
        wordCountContainer.appendChild(wordCountHeader);

        var wordCountBody = document.createElement('div');
        wordCountBody.style.display = 'none'; // Start hidden
        wordCountContainer.appendChild(wordCountBody);

        document.body.appendChild(wordCountContainer);

        wordCountHeader.addEventListener('click', function() {
            wordCountBody.style.display = wordCountBody.style.display === 'none' ? 'block' : 'none';
        });

        document.addEventListener('mouseup', function() {
            var selectedText = window.getSelection().toString().trim();
            if (selectedText.length > 0) {
                var words = selectedText.split(/\s+/).length;
                wordCountHeader.textContent = 'Word Count: ' + words + ' (Click to toggle)';
                wordCountBody.textContent = selectedText;
            }
        });

        // Add Focus Timer (Pomodoro Technique)
        var timerContainer = document.createElement('div');
        timerContainer.id = 'focus-timer-container';
        timerContainer.style.position = 'fixed';
        timerContainer.style.bottom = '130px';
        timerContainer.style.right = '10px';
        timerContainer.style.backgroundColor = 'rgba(0, 0, 0, 0.5)';
        timerContainer.style.color = 'white';
        timerContainer.style.padding = '5px 10px';
        timerContainer.style.borderRadius = '5px';
        timerContainer.style.fontFamily = 'Arial, sans-serif';
        timerContainer.style.fontSize = '14px';
        timerContainer.style.zIndex = '1000';
        timerContainer.style.cursor = 'pointer';

        var timerHeader = document.createElement('div');
        timerHeader.textContent = 'Focus Timer (Click to toggle)';
        timerContainer.appendChild(timerHeader);

        var timerBody = document.createElement('div');
        timerBody.style.display = 'none'; // Start hidden
        timerBody.textContent = 'Start Focus Session';
        timerContainer.appendChild(timerBody);

        var focusInterval;
        var focusTime = 25 * 60; // 25 minutes

        timerHeader.addEventListener('click', function() {
            timerBody.style.display = timerBody.style.display === 'none' ? 'block' : 'none';
        });

        timerBody.addEventListener('click', function() {
            if (focusInterval) {
                clearInterval(focusInterval);
                focusInterval = null;
                focusTime = 25 * 60;
                timerBody.textContent = 'Start Focus Session';
            } else {
                focusInterval = setInterval(function() {
                    var minutes = Math.floor(focusTime / 60);
                    var seconds = focusTime % 60;
                    timerBody.textContent = 'Focus Time: ' + minutes + ':' + (seconds < 10 ? '0' : '') + seconds;
                    if (--focusTime < 0) {
                        clearInterval(focusInterval);
                        focusInterval = null;
                        timerBody.textContent = 'Session Complete! Take a Break!';
                        alert('Focus session complete! Time for a break.');
                    }
                }, 1000);
            }
        });

        document.body.appendChild(timerContainer);
    });
})();