-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathlast-action-timestamp.user.js
87 lines (69 loc) · 3.41 KB
/
last-action-timestamp.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// ==UserScript==
// @author Zaso
// @name IITC plugin: Last Action Timestamp
// @category Info
// @version 0.0.3.20200216.174029
// @description Estimate the portal decaying.
// @id last-action-timestamp
// @namespace https://github.com/IITC-CE/ingress-intel-total-conversion
// @downloadURL https://github.com/MysticJay/ZasoItems.CE/raw/master/last-action-timestamp.user.js
// @match https://intel.ingress.com/*
// @grant none
// ==/UserScript==
function wrapper(plugin_info) {
// ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function') window.plugin = function() {};
//PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!!
//(leaving them in place might break the 'About IITC' page or break update checks)
plugin_info.buildName = 'ZasoItems';
plugin_info.dateTimeVersion = '2020-02-16-174029';
plugin_info.pluginId = 'last-action-timestamp';
//END PLUGIN AUTHORS NOTE
// PLUGIN START ////////////////////////////////////////////////////////
// History
// 0.0.3 Headers changed. Ready for IITC-CE
// 0.0.2 Original sript
// use own namespace for plugin
window.plugin.lastAction = function() {};
window.plugin.lastAction.convertTimestamp = function(timestamp){
var dt = window.unixTimeToDateTimeString(timestamp, true);
return dt;
}
window.plugin.lastAction.appendDetails = function(data){
var guid = window.selectedPortal;
var p = window.portals[guid];
var t = p.options.timestamp;
var dt = window.plugin.lastAction.convertTimestamp(t);
if(dt !== undefined && dt !== null){
dt = dt.slice(0, -4);
var helpTxt = 'The action is a recharge, deploy, upgrade, install a mod, link, fire, expires, but not hack or get xm';
var html = '<span style="cursor:help;" title="'+helpTxt+'">Last action</span>: <b>'+dt+'</b>';
$('#portaldetails .linkdetails').before('<div class="lastAction">'+html+'</div>');
}
}
//---------------------------------------------------------------------------------------
// Append the stylesheet
//---------------------------------------------------------------------------------------
window.plugin.lastAction.setupCSS = function(){
$('<style>').prop('type', 'text/css').html(''
+'.lastAction{text-align:center;padding:2px 0 3px;border:1px solid #20A8B1;border-width:1px 0;color:lightgrey;}'
+'.lastAction b{color:#ffc000;}'
).appendTo('head');
}
var setup = function() {
window.plugin.lastAction.setupCSS();
window.addHook('portalDetailsUpdated', window.plugin.lastAction.appendDetails);
};
// PLUGIN END //////////////////////////////////////////////////////////
setup.info = plugin_info; //add the script info data to the function as a property
if(!window.bootPlugins) window.bootPlugins = [];
window.bootPlugins.push(setup);
// if IITC has already booted, immediately run the 'setup' function
if(window.iitcLoaded && typeof setup === 'function') setup();
} // wrapper end
// inject code into site context
var script = document.createElement('script');
var info = {};
if (typeof GM_info !== 'undefined' && GM_info && GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description };
script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');'));
(document.body || document.head || document.documentElement).appendChild(script);