您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Show timestamps
当前为
// ==UserScript== // @name MHQ ago // @namespace none // @version 2018.11.27.1923 // @description Show timestamps // @supportURL https://Discord.me/TheShoeStore // @author technical13 // @match https://www.munzee.com/m/* // @grant none // ==/UserScript== // jshint esversion: 6 var isDebug = false; var intVerbosity = 0; const ver = '2018.11.27.1923'; const scriptName = 'MHQ ago v' + ver; function log( intV, strConsole, strLog, ...arrArgs ) { if ( strConsole === undefined ) { strConsole = 'log'; } if ( strLog === undefined ) { strLog = '%o'; } if ( intVerbosity >= intV && ( strConsole === 'groupEnd' ) ) { console[ strConsole ](); } if ( intV === 0 || ( isDebug && intVerbosity >= intV ) ) { console[ strConsole ]( '[%i]: %s: ' + strLog, intV, scriptName, ...arrArgs ); } } const intParamsStart = ( document.URL.indexOf( '?' ) + 1 ); const strParams = document.URL.substr( intParamsStart ); const arrParamSets = strParams.split( '&' ); var objParams = {}; arrParamSets.forEach( function( strParam ) { let arrParam = strParam.split( '=' ); let strParamName = ( arrParam[ 0 ].toLowerCase() || '' ); if ( strParamName === 'verbosity' ) { isDebug = toBoolean( arrParam[ 1 ] ); intVerbosity = ( arrParam[ 1 ] ? ( parseInt( arrParam[ 1 ] ) < 0 ? 0 : ( parseInt( arrParam[ 1 ] ) > 9 ? 9 : parseInt( arrParam[ 1 ] ) ) ) : 9 ); } else if ( strParamName === 'debug' ) { isDebug = toBoolean( arrParam[ 1 ] ); intVerbosity = 1; } } ); log( 1, 'warn', 'Debug mode is on with verbosity level: %o', intVerbosity ); log( 1, 'groupCollapsed', 'Verbosity options: (click to expand)' ); log( 1, 'log', '1) Summary\n2) Parameters retrieved from URL\n3) Variables set to objParams\n4) Function returns\n9) ALL debugging info and this notice.' ); log( 1, 'groupEnd' ); function toBoolean( val ) { const arrTrue = [ undefined, null, '', true, 'true', 1, '1', 'on', 'yes' ]; val = ( typeof( val ) === 'string' ? val.toLowerCase() : val ); log( 4, 'log', 'toBoolean() is returning: %o', ( arrTrue.indexOf( val ) !== -1 ? true : false ) ); return ( arrTrue.indexOf( val ) !== -1 ? true : false ); } const objFullTimeStringHQ = { year: 'numeric', month: 'long', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', timeZone: 'America/Chicago', timeZoneName: 'short', hour12: false }; const objShorTimeStringHQ = { year: 'numeric', month: 'short', day: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric', timeZone: 'America/Chicago', hour12: false }; const address = document.URL.replace( /https?:\/\/www\.munzee\.com\/m\//i, '' ).split( '/' ); const userName = ( address[ 0 ] || undefined ); const subPage = ( address[ 1 ] || undefined ); log( 1, 'info', 'userName = %s\nsubPage = %s', userName, subPage ); ( function() { 'use strict'; log( 0, 'info', 'Script loaded.' ); $( '.expires-at' ).each( function( i, elem ) { var strExpires = new Date( $( elem ).attr( 'title' ) ); var strNewExpires = strExpires.toLocaleDateString( 'en-US', objFullTimeStringHQ ) + ' (' + $( elem ).text().replace( 'in', '' ).trim() + ')</span>'; var strNudgeable = new Date( strExpires.setHours( strExpires.getHours() - 9 ) ); var strNewNudge = '<br /><span class="nudge-at" data-nudge-at="' + strNudgeable.valueOf() + '" title="' + strNudgeable.toISOString() + '">Nudgeable: ' + strNudgeable.toLocaleDateString( 'en-US', objFullTimeStringHQ ); $( elem ).html( strNewExpires + strNewNudge ); } ); $( '.deployed-at' ).each( function( i, elem ) { var strDeployed = new Date( $( elem ).attr( 'data-deployed-at' ) ); switch( subPage ) { case 'archived' : case 'captures' : case 'deploys' : $( elem ).append( '<br />' + strDeployed.toLocaleDateString( 'en-US', objShorTimeStringHQ ) ); break; case 'socials' : if ( address[ 2 ] === 'own' ) { $( elem ).append( '<br />' + strDeployed.toLocaleDateString( 'en-US', objShorTimeStringHQ ) ); } break; case 'kennel' : if ( address[ 2 ] === 'transported' ) { $( elem ).append( '<br />' + strDeployed.toLocaleDateString( 'en-US', objFullTimeStringHQ ) ); } break; case 'blast' : case 'feed' : default: if ( !isNaN( address[ 2 ] ) ) { $( elem ).append( '<br />' + strDeployed.toLocaleDateString( 'en-US', objFullTimeStringHQ ) ); } else { $( elem ).text( strDeployed.toLocaleDateString( 'en-US', objFullTimeStringHQ ) + ' (' + $( elem ).text() + ')' ); } } } ); $( '.captured-at' ).each( function( i, elem ) { var strCaptured = new Date( $( elem ).attr( 'data-captured-at' ) ); switch( subPage ) { case 'archived' : case 'captures' : case 'deploys' : $( elem ).append( '<br />' + strCaptured.toLocaleDateString( 'en-US', objShorTimeStringHQ ) ); break; case 'socials' : if ( address[ 2 ] === 'own' ) { $( elem ).append( '<br />' + strCaptured.toLocaleDateString( 'en-US', objShorTimeStringHQ ) ); } break; case 'kennel' : if ( address[ 2 ] === 'transported' ) { $( elem ).append( '<br />' + strCaptured.toLocaleDateString( 'en-US', objFullTimeStringHQ ) ); } break; case 'blast' : case 'feed' : default: $( elem ).text( strCaptured.toLocaleDateString( 'en-US', objFullTimeStringHQ ) + ' (' + $( elem ).text() + ')' ); } } ); $( '.blasted-at' ).each( function( i, elem ) { var strBlasted = new Date( $( elem ).attr( 'data-blasted-at' ) ); $( elem ).append( '<p>' + strBlasted.toLocaleDateString( 'en-US', objFullTimeStringHQ ) + '</p>' ); } ); } )();