-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathagent.user.js
54 lines (48 loc) · 2.06 KB
/
agent.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
// ==UserScript==
// @author tunmenee
// @id agent-opener
// @name Open Agent Profile
// @category Misc
// @version 1.0
// @namespace none
// @description Click on agent name to open it in the game.
// @include https://intel.ingress.com/intel*
// @match https://intel.ingress.com/intel*
// @grant none
// ==/UserScript==
function wrapper(plugin_info) {
if (typeof window.plugin !== 'function') window.plugin = function () { };
plugin_info.buildName = 'agent-opener';
plugin_info.dateTimeVersion = '1';
plugin_info.pluginId = 'agent-opener';
function setup() {
//for every class "nickname" in whole document, prevent other js from running $(document).on('click', '.nickname', function(event)
$(document).on('click', '.nickname', function (event) {
//show alert to ask if user wants to open agent profile
if (confirm("Open " + $(this).text() + "'s profile?\n\n(Called by Agent Opener plugin)")) {
//get agent name from the class "nickname"
var agentName = $(this).text();
//open agent profile in game https://link.ingress.com/?link=https://intel.ingress.com/agent/nickname
window.open("https://link.ingress.com/?link=https://intel.ingress.com/agent/" + agentName, "_blank");
} else {
//do nothing
}
});
}
setup.info = plugin_info;
if (!window.bootPlugins) window.bootPlugins = [];
window.bootPlugins.push(setup);
if (window.iitcLoaded && typeof setup === 'function') setup();
}
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
};
}
var textContent = document.createTextNode('(' + wrapper + ')(' + JSON.stringify(info) + ')');
script.appendChild(textContent);
(document.body || document.head || document.documentElement).appendChild(script);