Guest User

CellMapperに楽天モバイルエリアを表示させるUserScript

a guest
Aug 8th, 2020
1,885
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name     Cellmapper add RakutenMobile layer
  3. // @version  1
  4. // @grant    GM_addStyle
  5. // @include  https://www.cellmapper.net/map*
  6. // ==/UserScript==
  7.  
  8. // Cellmapperに楽天モバイル自社エリアを表示するユーザースクリプト。
  9. // Chrome+Tampermonkey と Firefox+GreaseMonkey にて動作確認。
  10.  
  11. const add_rmi_layer = function(){
  12.   setTimeout(function(){
  13.   console.log('start');
  14.   const map = window.map;
  15.   console.log(map);
  16.   const rmi = new ol.layer.Tile({
  17.     source: new ol.source.XYZ({
  18.       url: "https://gateway-api.global.rakuten.com/dsd/geoserver/mno_coverage_map/gwc/service/gmaps?LAYERS=mno_coverage_map:rmi&FORMAT=image/png&TRANSPARENT=TRUE&x={x}&y={y}&zoom={z}",
  19.       projection: "EPSG:3857"
  20.     })
  21.   });
  22.   map.addLayer(rmi);
  23.   console.log('end');
  24.   },3000);
  25. }
  26.  
  27. addJS_Node (null, null, add_rmi_layer);
  28.  
  29. function addJS_Node (text, s_URL, funcToRun, runOnLoad) {
  30.     // see: https://stackoverflow.com/questions/13485122/accessing-variables-from-greasemonkey-to-page-vice-versa/13485650#13485650
  31.     var D                                   = document;
  32.     var scriptNode                          = D.createElement ('script');
  33.     if (runOnLoad) {
  34.         scriptNode.addEventListener ("load", runOnLoad, false);
  35.     }
  36.     scriptNode.type                         = "text/javascript";
  37.     if (text)       scriptNode.textContent  = text;
  38.     if (s_URL)      scriptNode.src          = s_URL;
  39.     if (funcToRun)  scriptNode.textContent  = '(' + funcToRun.toString() + ')()';
  40.  
  41.     var targ = D.getElementsByTagName ('head')[0] || D.body || D.documentElement;
  42.     targ.appendChild (scriptNode);
  43. }
RAW Paste Data