NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Watch nba local time // @namespace http://tampermonkey.net/ // @require https://gist.github.com/raw/2625891/waitForKeyElements.js // @require https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.19.1/moment.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.14/moment-timezone-with-data.min.js // @version 1.3.0 // @description Show time in watch.nba.com calendar in your local time instead of Eastern Day Timezone. // @author ArthurHlt // @copyright 2017, Arthur Halet // @match https://watch.nba.com/* // @grant none // ==/UserScript== waitForKeyElements(".team-time", changeTime); waitForKeyElements(".game-situation", changeGameSituation); function changeGameSituation(jNode){ if($('.team-phase', jNode).length){ return; } if($('.desc', jNode).length) { changeTime($('.desc', jNode)); return; } changeTime(jNode); } function changeTime(jNode){ var when = " PM"; if($("span", jNode).length == 0){ when = ""; }else{ var zone = $("span", jNode).text().trim(); if(!zone.startsWith('Ap')){ when = " AM"; } $("span", jNode).remove(); } var regIsTime = /^[0-9]{1,2}/; var timeText = $(jNode).text().trim(); if(!timeText.match(regIsTime)){ return; } var teamDateElem = $('.team-date', $(jNode).parent()); var teamTime = null; var teamLocalTime = null; if(teamDateElem.length == 0){ teamTime = moment.tz($(jNode).text() + when, 'h:m A', "America/New_York"); teamLocalTime = moment(teamTime.format()); }else{ teamTime = moment.tz(teamDateElem.text() +' '+ $(jNode).text() + when, 'DD/MM h:m A', "America/New_York"); teamLocalTime = moment(teamTime.format()); teamDateElem.text(teamLocalTime.format('DD/MM')); } $(jNode).text(teamLocalTime.format('HH:mm')); }