-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathforce-zoomlevel.user.js
150 lines (125 loc) · 5.19 KB
/
force-zoomlevel.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
// ==UserScript==
// @id iitc-plugin-force-zoomlevel
// @name IITC plugin: Force Zoom Level
// @category Tweaks
// @version 0.2.0.20250309.190933
// @author Konano
// @namespace https://github.com/Konano/iitc-plugins
// @description Force IITC to load all portals, all links, or default regardless of zoom level.
// @homepageURL https://github.com/Konano/iitc-plugins
// @updateURL https://github.com/Konano/iitc-plugins/raw/main/force-zoomlevel.user.js
// @downloadURL https://github.com/Konano/iitc-plugins/raw/main/force-zoomlevel.user.js
// @supportURL https://github.com/Konano/iitc-plugins/issues
// @match https://intel.ingress.com/*
// @license MIT
// @grant none
// ==/UserScript==
function wrapper(plugin_info) {
// Make sure that window.plugin exists
if (typeof window.plugin !== 'function') window.plugin = function () { };
// PLUGIN INFO ////////////////////////////////////////////////////////
plugin_info.buildName = 'forceZoomLevel';
plugin_info.dateTimeVersion = '20250309.190933';
plugin_info.pluginId = 'force-zoomlevel';
// PLUGIN START ////////////////////////////////////////////////////////
// Use own namespace for plugin
window.plugin.forceZoomLevel = function () { };
var self = window.plugin.forceZoomLevel;
self.mode = 'Default';
self.functionsOverwritten = false;
self.zoomOptions = {
'Default': 'Default',
'AllLinks': 'All Links',
'AllPortals': 'All Portals'
};
self.showDialog = function () {
var div = document.createElement('div');
div.appendChild(document.createTextNode('Select a forced zoom level: '));
div.appendChild(document.createElement('br'));
for (var option in self.zoomOptions) {
var label = div.appendChild(document.createElement('label'));
var input = label.appendChild(document.createElement('input'));
input.type = 'radio';
input.name = 'plugin-force-zoomlevel';
input.value = option;
if (option === self.mode) {
input.checked = true;
}
input.addEventListener('click', function (opt) {
return function () {
self.setMode(opt);
}
}(option), false);
label.appendChild(document.createTextNode(' ' + self.zoomOptions[option]));
div.appendChild(document.createElement('br'));
}
dialog({
id: 'plugin-force-zoomlevel',
html: div,
title: 'Force Zoom Level',
});
};
self.setMode = function (mode) {
self.mode = mode;
localStorage['plugin-forcezoomlevel-mode'] = mode;
switch (mode) {
case 'Default':
window.getDataZoomForMapZoom = window.getDataZoomForMapZoomDefault;
break;
case 'AllLinks':
window.getDataZoomForMapZoom = window.getDataZoomForMapZoomAllLinks;
break;
case 'AllPortals':
window.getDataZoomForMapZoom = window.getDataZoomForMapZoomAllPortals;
break;
}
window.mapDataRequest.start();
};
self.init = function () {
$('#toolbox').append(' <a onclick="window.plugin.forceZoomLevel.showDialog()">Force Zoom Opt</a>');
window.getDataZoomForMapZoomDefault = window.getDataZoomForMapZoom;
window.getDataZoomForMapZoomAllLinks = function () { return 13; };
window.getDataZoomForMapZoomAllPortals = function () { return 17; };
try {
var mode = localStorage['plugin-forcezoomlevel-mode'];
if (typeof (mode) === 'undefined') {
mode = 'Default';
}
self.setMode(mode);
} catch (e) {
console.warn(e);
self.mode = 'Default';
}
console.log('Force Zoom Level: Plugin loaded');
};
// The entry point for this plugin
function setup() {
// Wait until IITC is loaded
window.addHook('iitcLoaded', self.init);
}
// Add plugin info
setup.info = plugin_info;
// Add our startup hook
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();
}
// 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);