Year Process

try to take over the world!

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name         Year Process
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  try to take over the world!
// @author       YP
// @require      https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @include      *
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    var yearProcess = document.createElement("div");
    yearProcess.innerHTML = '<div id="pbar_outerdiv" style="width: 300px; height: 20px; border: 1px solid grey; z-index: 1; position: relative; border-radius: 5px; -moz-border-radius:  5px; margin-left: auto; margin-right: auto;"> ' +
        '<div id="pbar_innerdiv" style="background-color: #1E9FFF!important; z-index: 2; height: 100%; width: 0%; border-radius:  5px; -moz-border-radius:  5px;"></div>' +
        '<div id="pbar_innertext" style="z-index: 3; position: absolute; top: 0; left: 0; width: 100%; line-height: 20px; color: black; font-weight: bold; text-align: center;">0%</div> ' +
        '</div>';
    document.body.insertBefore(yearProcess, document.body.firstChild);

    var start = new Date((new Date()).getFullYear(), 0, 1);
    var maxTime = 365 * 24 * 60 * 60 * 1000;
    var timeoutVal = Math.floor(maxTime / 100);
    animateUpdate();
    var theDiv = document.getElementById('pbar_outerdiv');
    window.setTimeout(function() {
        if (theDiv) {
            theDiv.parentNode.removeChild(theDiv);
        }
    },
    5 * 1000);

    function updateProgress(percentage) {
        $('#pbar_innerdiv').css("width", percentage + "%");
        $('#pbar_innertext').text(percentage + "%");
    }

    function animateUpdate() {
        var now = new Date();
        var timeDiff = now.getTime() - start.getTime();
        var perc = ((timeDiff / maxTime) * 100).toFixed(2);
        console.log(perc);
        if (perc <= 100) {
            updateProgress(perc);
            setTimeout(animateUpdate, timeoutVal);
        } else { // It got 100%
            updateProgress(100);
        }
    }
})();