// ==UserScript==
// @name IITC plugin: OpenCycleMap.org map tiles add-on
// @version 1.0.1.20220712.094300
// @updateURL https://softspot.nl/ingress/plugins/iitc-plugin-basemap-opencyclemap-addon.meta.js
// @downloadURL https://softspot.nl/ingress/plugins/iitc-plugin-basemap-opencyclemap-addon.user.js
// @description [danielondiordna-1.0.1.20220712.094300] Add-on to set an API KEY for the Thunderforest map tiles (OpenCycleMap). To make things easier, the Add-on already includes the code from the OpenCycleMap plugin.
// @author DanielOnDiordna
// @namespace https://softspot.nl/ingress/
// @match https://intel.ingress.com/*
// @grant none
// @id iitc-plugin-basemap-opencyclemap-addon@danielondiordna
// @category Addon
// ==/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() {};
// use own namespace for plugin
window.plugin.basemapOpenCycleMapAddon = function() {};
var self = window.plugin.basemapOpenCycleMapAddon;
self.id = 'basemapOpenCycleMapAddon';
self.title = 'OpenCycleMap Addon';
self.version = '1.0.1.20220712.094300';
self.author = 'DanielOnDiordna';
self.changelog = `
Changelog:
version 1.0.1.20220712.094300
- removed some console debugging messages
version 1.0.0.20220710.185000
- fixed keeping selected Thunderforest map active after IITC reloads
- changed words for the dialog and alert texts
- added 5 more maps found at the Thunderforest website (total of 10)
version 0.0.4.20210724.002500
- prevent double plugin setup on hook iitcLoaded
version 0.0.4.20210421.190200
- minor fix for IITC CE where runHooks iitcLoaded is executed before addHook is defined in this plugin
version 0.0.4.20210124.184400
- modify every link from http: to https:
version 0.0.3.20210121.224000
- version number fix
version 0.0.2.20210117.190200
- added source code from https://static.iitc.me/build/release/plugins/basemap-opencyclemap.user.js
- added API key check and popups
- updated plugin wrapper and userscript header formatting to match IITC-CE coding
version 0.0.1.20191023.001600
- first release
`;
self.namespace = 'window.plugin.' + self.id + '.';
self.pluginname = 'plugin-' + self.id;
self.settings = {};
self.settings.apikey = "";
self.storeSettings = function() {
localStorage[self.pluginname + '-settings'] = JSON.stringify(self.settings);
};
self.restoreSettings = function() {
if (localStorage[self.pluginname + '-settings']) {
let settings = JSON.parse(localStorage[self.pluginname + '-settings']);
if (typeof settings === 'object' && settings instanceof Object) {
if (typeof settings.apikey === 'string') self.settings.apikey = settings.apikey;
}
}
};
self.enterApiKey = function() {
let newapikey = prompt("Enter API key:",self.settings.apikey);
if (newapikey == null) return;
self.settings.apikey = newapikey;
self.storeSettings();
self.updateApiKey();
if (newapikey) {
alert('The Thunderforest (OpenCycleMap) map tiles are now available (if your API key is valid)');
} else {
alert('Without an API key, The Thunderforest (OpenCycleMap) map tiles will mention: API key required');
}
};
self.menu = function() {
let container = document.createElement('div');
container.className = `${self.id}-dialog`;
container.innerHTML = `
The OpenCycleMap (Thunderforest) map tiles require a personal API key.
Without an API key, The Thunderforest (OpenCycleMap) map tiles will mention: API key required
Disable the OpenCycleMap plugin (and add-on) if you do not have an API key. Sign up and get your free API keyEnter/view API key