Skip to content

Instantly share code, notes, and snippets.

@prahladyeri
Created August 28, 2018 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prahladyeri/b66ba873106474520577ff744aa1ed46 to your computer and use it in GitHub Desktop.
Save prahladyeri/b66ba873106474520577ff744aa1ed46 to your computer and use it in GitHub Desktop.
Userscript to add auto-refresh functionality to GMail Classic
// ==UserScript==
// @name GMail Classic
// @namespace https://prahladyeri.com
// @version 0.1
// @description Add refresh timer to GMail Classic
// @author Prahlad Yeri
// @match https://mail.google.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
var seconds = 300; //5 mins
var interval = seconds * 1000;
var remaining = interval;
var btn = document.createElement("button");
btn.id = 'btnRefresh';
btn.textContent = "Refresh (" + (remaining/1000) + " seconds)";
btn.onclick = function() {
window.location = location;
}
$("div#gbar").append(btn);
setInterval(refreshMe, interval);
setInterval(function(){
remaining = remaining - 1000;
btn.textContent = "Refresh (" + (remaining/1000) + " seconds)";
}, 1000);
//
function refreshMe() {
window.location = window.location;
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment