Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jscher2000/3ff0d847db967a3d8c2385a5de05a677 to your computer and use it in GitHub Desktop.
Save jscher2000/3ff0d847db967a3d8c2385a5de05a677 to your computer and use it in GitHub Desktop.
Fix Gmail Message Times When Resisting Fingerprinting (user script / pre-alpha)
// ==UserScript==
// @name Fix Gmail Message Times When Resisting Fingerprinting
// @author Jefferson "jscher2000" Scher
// @namespace JeffersonScher
// @version 0.1 Pre-Alpha
// @copyright Copyright 2018 Jefferson Scher
// @license BSD-3-Clause
// @include https://mail.google.com/mail/*
// @grant GM_registerMenuCommand
// ==/UserScript==
var UTCOffset = -7; // Your personal offset from UTC
var localePref = 'en-US'; // Your preferred locale for time format
var dtadj = UTCOffset * 1000 * 60 * 60;
var dnow = new Date(Date.now() + dtadj);
function fixTimes(){
if (location.hash.indexOf('/') > -1) { // individual message?
} else { // message list?
var dtspans = document.querySelectorAll('td.xW.xY span[title]'), d, dtitle;
for (i = 0; i < dtspans.length; i++){
if (dtspans[i].getAttribute('title') == dtspans[i].getAttribute('aria-label')){
d = new Date(Date.parse(dtspans[i].getAttribute('title').replace(' at', '')) + dtadj);
dtitle = d.toDateString() + ' at ' + d.toLocaleTimeString(localePref);
dtspans[i].setAttribute('title', dtitle);
if (d.getMonth() == dnow.getMonth() && d.getDate() == dnow.getDate()){
if (dtspans[i].innerHTML.indexOf('<b>') == 0) {
dtspans[i].innerHTML = '<b>' + d.toLocaleTimeString(localePref).replace(':00 ', ' ') + '</b>';
} else {
dtspans[i].textContent = d.toLocaleTimeString(localePref).replace(':00 ', ' ');
}
} else {
if (dtspans[i].innerHTML.indexOf('<b>') == 0) {
dtspans[i].innerHTML = '<b>' + ['Jan ','Feb ','Mar ','Apr ','May ','Jun ','Jul ','Aug ','Sep ','Oct ','Nov ','Dec '][d.getMonth()] + d.getDate() + '</b>';
} else {
dtspans[i].textContent = ['Jan ','Feb ','Mar ','Apr ','May ','Jun ','Jul ','Aug ','Sep ','Oct ','Nov ','Dec '][d.getMonth()] + d.getDate();
}
}
}
}
}
}
GM_registerMenuCommand("Tweak Dates", fixTimes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment