-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmobile.user.js
109 lines (94 loc) · 3.74 KB
/
mobile.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
// ==UserScript==
// @author tunmenee on https://vim.li
// @id mobile-open
// @name Open Portal In Scanner
// @category Misc
// @version 1.0.2
// @namespace https://github.com/ManjTi/IITC-Plugin-Open-Mobile/
// @description Open selected portal in scanner (mobile only)
// @updateURL https://raw.githubusercontent.com/ManjTi/IITC-Plugin-Open-Mobile/main/mobile.meta.js
// @downloadURL https://raw.githubusercontent.com/ManjTi/IITC-Plugin-Open-Mobile/main/mobile.user.js
// @runAt document-end
// @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 = 'mobile-open';
plugin_info.dateTimeVersion = '1';
plugin_info.pluginId = 'mobile-open';
function setup() {
//add css
$('<style>').prop('type', 'text/css').html(`
.mobilelink {
margin: -30px 0px 0px calc(50% - 112px);
position: fixed;
right: 0px;
}
.mobilelink a {
color: white;
background-color: #9430e9;
padding: 5px;
text-weight: bold;
display: block;
width: fit-content;
text-align: center;
}
@keyframes pulse {
0% {
transform: scale(1);
box-shadow: 0 0 0 0 rgba(148, 48, 233, 0.4);
}
70% {
transform: scale(1);
box-shadow: 0 0 0 10px rgba(148, 48, 233, 0);
}
100% {
transform: scale(1);
box-shadow: 0 0 0 0 rgba(148, 48, 233, 0);
}
}
`).appendTo('head');
window.addHook('portalSelected', updateMobile);
}
//link structure https://link.ingress.com/?link=https://intel.ingress.com/portal/guid'
function updateMobile(data) {
var guid = data.selectedPortalGuid;
var url = 'https://link.ingress.com/?link=https://intel.ingress.com/portal/' + guid;
var html = '<a href="' + url + '" target="_blank">Open in scanner</a>';
//add to updatestatus container
//if already exists, replace
$("#updatestatus").find(".mobilelink").remove();
//add before the first child
$("#updatestatus").prepend('<div class="mobilelink">' + html + '</div>');
//add animation once
$(".mobilelink").addClass("animated pulse 1s");
}
// Add an info property for IITC's plugin system
setup.info = plugin_info;
// Make sure window.bootPlugins exists and is an array
if (!window.bootPlugins) window.bootPlugins = [];
// Add our startup hook
window.bootPlugins.push(setup);
// If IITC has already booted, immediately run the 'setup' function
if (window.iitcLoaded && typeof setup === 'function') setup();
}
// Create a script element to hold our content script
var script = document.createElement('script');
var info = {};
// GM_info is defined by the assorted monkey-themed browser extensions
// and holds information parsed from the script header.
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
};
}
// Create a text node and our IIFE inside of it
var textContent = document.createTextNode('(' + wrapper + ')(' + JSON.stringify(info) + ')');
// Add some content to the script element
script.appendChild(textContent);
// Finally, inject it... wherever.
(document.body || document.head || document.documentElement).appendChild(script);