Advertisement
Guest User

Untitled

a guest
Apr 28th, 2017
383
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.53 KB | None | 0 0
  1. // ==UserScript==
  2. // @id iitc-plugin-superdata@anonymous_in_sf
  3. // @name Load all portals/links
  4. // @category Info
  5. // @version 0.0.1.20160513.52655
  6. // @namespace https://github.com/jonatkins/ingress-intel-total-conversion
  7. // @updateURL http://distomatic.s3-website-us-east-1.amazonaws.com/iitc/plugins/map-superdata.meta.js
  8. // @downloadURL http://distomatic.s3-website-us-east-1.amazonaws.com/iitc/plugins/map-superdata.user.js
  9. // @description [distomatic-2016-05-13-052655]
  10. // @include https://www.ingress.com/intel*
  11. // @include http://www.ingress.com/intel*
  12. // @match https://www.ingress.com/intel*
  13. // @match http://www.ingress.com/intel*
  14. // @include https://www.ingress.com/mission/*
  15. // @include http://www.ingress.com/mission/*
  16. // @match https://www.ingress.com/mission/*
  17. // @match http://www.ingress.com/mission/*
  18. // @grant none
  19. // ==/UserScript==
  20.  
  21.  
  22. function wrapper(plugin_info) {
  23. // ensure plugin framework is there, even if iitc is not yet loaded
  24. if(typeof window.plugin !== 'function') window.plugin = function() {};
  25.  
  26. //PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!!
  27. //(leaving them in place might break the 'About IITC' page or break update checks)
  28. plugin_info.buildName = 'distomatic';
  29. plugin_info.dateTimeVersion = '20160513.52655';
  30. plugin_info.pluginId = 'map-superdata';
  31. //END PLUGIN AUTHORS NOTE
  32.  
  33.  
  34.  
  35. // PLUGIN START ////////////////////////////////////////////////////////
  36.  
  37. // use own namespace for plugin
  38. window.plugin.superData = function() {};
  39.  
  40. var ZOOM_DEFAULT = 0;
  41. var ZOOM_ALL_LINKS = 1;
  42. var ZOOM_ALL_PORTALS = 2;
  43. var ZOOM_MAX_MODE = ZOOM_ALL_PORTALS;
  44. var mode_text = [ "default", "all links", "all portals" ];
  45. var standard_zoom;
  46.  
  47. window.plugin.superData.mode = ZOOM_DEFAULT;
  48.  
  49. // XXX we need to re-think this.
  50. // What if someone called us when MapZoom was somewhere around 3? That would be *insane*
  51. // We need to limit the maximum number of boost steps.
  52. // if <9 refuse all links
  53. // if <13 or 14, refuse all portals
  54.  
  55. window.plugin.superData.getDataZoomForMapZoom = function(zoom) {
  56. var mode = window.plugin.superData.mode;
  57. var map_zoom = zoom;
  58.  
  59. if (mode === ZOOM_DEFAULT)
  60. return standard_zoom(zoom);
  61.  
  62. // only boost up a few levels (this should be a percentage,
  63. // not a fixed number, 4 may be too large)
  64. while (zoom < 21 && (zoom - map_zoom < 5)) {
  65. var params = window.getMapZoomTileParameters(zoom);
  66.  
  67. if ((mode === ZOOM_ALL_LINKS && params.minLinkLength === 0) ||
  68. (mode === ZOOM_ALL_PORTALS && params.hasPortals))
  69. break;
  70.  
  71. zoom = zoom + 1;
  72. }
  73. return zoom;
  74. };
  75.  
  76. window.plugin.superData.setmode = function(mode) {
  77. var old_zoom = window.getDataZoomForMapZoom(map.getZoom());
  78.  
  79. window.plugin.superData.mode = mode;
  80. $('#superdata-status').html(mode_text[mode]);
  81.  
  82. if (old_zoom < window.getDataZoomForMapZoom(map.getZoom())) {
  83. window.mapDataRequest.start();
  84. }
  85. };
  86.  
  87. window.plugin.superData.toggle = function() {
  88. var new_mode = (window.plugin.superData.mode + 1) % (ZOOM_MAX_MODE+1);
  89. window.plugin.superData.setmode(new_mode);
  90. };
  91.  
  92. window.plugin.superData.setup = function() {
  93. $('#updatestatus').prepend('<div id="superdata" style="padding-bottom: 8px;"><strong>Get More Info:</strong> <span id="superdata-status"></span></div>');
  94. $('#superdata').click(window.plugin.superData.toggle);
  95.  
  96. standard_zoom = window.getDataZoomForMapZoom;
  97. window.getDataZoomForMapZoom = window.plugin.superData.getDataZoomForMapZoom;
  98. window.plugin.superData.setmode(ZOOM_DEFAULT);
  99. };
  100.  
  101. var setup = window.plugin.superData.setup;
  102.  
  103. // PLUGIN END //////////////////////////////////////////////////////////
  104.  
  105.  
  106. setup.info = plugin_info; //add the script info data to the function as a property
  107. if(!window.bootPlugins) window.bootPlugins = [];
  108. window.bootPlugins.push(setup);
  109. // if IITC has already booted, immediately run the 'setup' function
  110. if(window.iitcLoaded && typeof setup === 'function') setup();
  111. } // wrapper end
  112. // inject code into site context
  113. var script = document.createElement('script');
  114. var info = {};
  115. 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 };
  116. script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');'));
  117. (document.body || document.head || document.documentElement).appendChild(script);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement