diff --git a/code/boot.js b/code/boot.js index d0391cf6..1d9ef3c8 100644 --- a/code/boot.js +++ b/code/boot.js @@ -279,13 +279,23 @@ function asyncLoadScript(a){return function(b,c){var d=document.createElement("s // modified version of https://github.com/shramov/leaflet-plugins. Also // contains the default Ingress map style. -var LLGMAPS = 'http://breunigs.github.com/ingress-intel-total-conversion/dist/leaflet_google.js'; +var LEAFLETGOOGLE = 'http://breunigs.github.com/ingress-intel-total-conversion/dist/leaflet_google.js'; var JQUERY = 'https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'; var JQUERYUI = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js'; var LEAFLET = 'http://cdn.leafletjs.com/leaflet-0.5/leaflet.js'; var AUTOLINK = 'http://breunigs.github.com/ingress-intel-total-conversion/dist/autolink.js'; +var EMPTY = 'data:text/javascript;base64,'; + +// don’t download resources which have been injected already +var ir = window && window.internalResources ? window.internalResources : []; +if(ir.indexOf('jquery') !== -1) JQUERY = EMPTY; +if(ir.indexOf('jqueryui') !== -1) JQUERYUI = EMPTY; +if(ir.indexOf('leaflet') !== -1) LEAFLET = EMPTY; +if(ir.indexOf('autolink') !== -1) AUTOLINK = EMPTY; +if(ir.indexOf('leafletgoogle') !== -1) LEAFLETGOOGLE = EMPTY; + // after all scripts have loaded, boot the actual app -load(JQUERY, LEAFLET, AUTOLINK).then(LLGMAPS, JQUERYUI).onError(function (err) { +load(JQUERY, LEAFLET, AUTOLINK).then(LEAFLETGOOGLE, JQUERYUI).onError(function (err) { alert('Could not all resources, the script likely won’t work.\n\nIf this happend the first time for you, it’s probably a temporary issue. Just wait a bit and try again.\n\nIf you installed the script for the first time and this happens:\n– try disabling NoScript if you have it installed\n– press CTRL+SHIFT+K in Firefox or CTRL+SHIFT+I in Chrome/Opera and reload the page. Additional info may be available in the console.\n– Open an issue at https://github.com/breunigs/ingress-intel-total-conversion/issues'); }).thenRun(boot); diff --git a/main.js b/main.js index 00904d65..2b2fb881 100644 --- a/main.js +++ b/main.js @@ -49,15 +49,23 @@ for(var i = 0; i < d.length; i++) { // player information is now available in a hash like this: // window.PLAYER = {"ap": "123", "energy": 123, "available_invites": 123, "nickname": "somenick", "team": "ALIENS||RESISTANCE"}; +var ir = window.internalResources || []; + // remove complete page. We only wanted the user-data and the page’s // security context so we can access the API easily. Setup as much as // possible without requiring scripts. document.getElementsByTagName('head')[0].innerHTML = '' //~ + '' + 'Ingress Intel Map' - + '' - + '' - + ''; + + (ir.indexOf('mainstyle') === -1 + ? '' + : '') + + (ir.indexOf('leafletcss') === -1 + ? '' + : '') + + (ir.indexOf('codafont') === -1 + ? '' + : ''); document.getElementsByTagName('body')[0].innerHTML = '' + '
Loading, please wait
'