-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforce-zoom-level.user.js
More file actions
128 lines (103 loc) · 4.55 KB
/
force-zoom-level.user.js
File metadata and controls
128 lines (103 loc) · 4.55 KB
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
// ==UserScript==
// @name IITC plugin: Force Zoom Level
// @namespace https://github.com/IITC-CE/ingress-intel-total-conversion
// @category Tweaks
// @version 0.1.3
// @description [local-2023-10-13-131313] Force IITC to load all portals, all links, or default regardless of zoom level.
// @author unknown
// @id iitc-plugin-force-zoomlevel@unknown
// @downloadURL https://raw.githubusercontent.com/suncj98/raws/main/force-zoom-level.user.js
// @updateURL https://raw.githubusercontent.com/suncj98/raws/main/force-zoom-level.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 = 'local';
plugin_info.dateTimeVersion = '20170312.40451';
plugin_info.pluginId = 'force-zoomlevel';
//END PLUGIN AUTHORS NOTE
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.forceZoomLevel = function() {};
window.plugin.forceZoomLevel.mode = 'Default';
window.plugin.forceZoomLevel.functionsOverwritten = false;
window.plugin.forceZoomLevel.zoomOptions = {
'Default' : 'Default',
'AllLinks' : 'All Links',
'AllPortals' : 'All Portals'
};
window.plugin.forceZoomLevel.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 window.plugin.forceZoomLevel.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 === window.plugin.forceZoomLevel.mode) {
input.checked = true;
}
input.addEventListener('click', function(opt) { return function() {
window.plugin.forceZoomLevel.setMode(opt);
} }(option), false);
label.appendChild(document.createTextNode(' ' + window.plugin.forceZoomLevel.zoomOptions[option]));
div.appendChild(document.createElement('br'));
}
dialog({
id: 'plugin-force-zoomlevel',
html: div,
title: 'Force Zoom Level',
});
};
window.plugin.forceZoomLevel.setMode = function (mode) {
window.plugin.forceZoomLevel.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();
}
window.plugin.forceZoomLevel.setup = function() {
$('#toolbox').append(' <a onclick="window.plugin.forceZoomLevel.showDialog()"><B>Force Zoom Opt</B></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';
}
window.plugin.forceZoomLevel.setMode(mode);
} catch(e) {
console.warn(e);
window.plugin.forceZoomLevel.mode = 'Default';
}
};
var setup = window.plugin.forceZoomLevel.setup;
// 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);