Created
November 9, 2019 14:52
-
-
Save johnd0e/f8594b6763a7d33cfd53d3a7f27ac5b0 to your computer and use it in GitHub Desktop.
IITC plugin: Tile grid lines fix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @id fix-tiles-gap | |
// @name IITC plugin: Tile grid lines fix | |
// @category Fix | |
// @version 0.1 | |
// @description Workaround for 1px-gap between tiles (https://github.com/Leaflet/Leaflet/issues/6101#issuecomment-480593514) | |
// @namespace https://github.com/johnd0e | |
// @include 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() {}; | |
function setup () { | |
/* | |
* Workaround for 1px lines appearing in some browsers due to fractional transforms | |
* and resulting anti-aliasing. | |
* https://github.com/Leaflet/Leaflet/issues/3575 | |
*/ | |
(function (_initTile) { | |
L.GridLayer.include({ | |
_initTile: function (tile) { | |
_initTile.call(this, tile); | |
var tileSize = this.getTileSize(); | |
tile.style.width = tileSize.x + 1 + 'px'; | |
tile.style.height = tileSize.y + 1 + 'px'; | |
} | |
}); | |
})(L.GridLayer.prototype._initTile) | |
} | |
setup.priority = 'high'; | |
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); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment