VivifyGmail

Keep your POP3 account in Gmail with latest infomation

Από την 23/09/2017. Δείτε την τελευταία έκδοση.

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         VivifyGmail
// @namespace    https://github.com/jonas0616/vivifygmail
// @version      0.1
// @description  Keep your POP3 account in Gmail with latest infomation
// @author       jonas0616
// @grant        none
// @include      https://mail.google.com/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @license      Apache License 2.0
// ==/UserScript==

(function() {
    'use strict';

    Promise.resolve()

    .then(() => {
        return new Promise((resolve) => {
            let id = setInterval(() => {
				if (window.GM_ACTION_TOKEN !== undefined &&
					window.GLOBALS !== undefined
				) {
					clearInterval(id);
					resolve();
				}
			}, 5000);
        });
    })

    .then((data) => {
        let url = window.location.href.split('#')[0];
		let at = window.GM_ACTION_TOKEN;
		let ik = window.GLOBALS[9];

        // check act is valid
		let refreshUrl = `${url}?ik=${ik}&&at=${at}&view=up&act=par&rt=j`;

		// repeat by one minute
		window.setInterval(() => {
			refresh(refreshUrl);
		}, 60000);
    });

	function refresh(refreshUrl) {
		console.log(refreshUrl);
		$.ajax({
			url: refreshUrl,
			method: 'POST',
			xhr: () => {
				let xhr = $.ajaxSettings.xhr();
				let setRequestHeader = (name, value) => {
					// ignore X-Requested-With
					if (name === 'X-Requested-With') {
						return;
					}
					setRequestHeader.call(this, name, value);
				};
				return xhr;
			}
		})

		.catch((err) => {
			console.log(err);
		});
	}

})();