m24111

Untitled

Jun 22nd, 2020
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         DS - Extra Grids
  3. // @namespace    http://tampermonkey.net/
  4. // @version      0.1
  5. // @description  try to take over the world!
  6. // @author       XHunter
  7. // @match        *://command.drop-shock.com/map_viewer.php*
  8. // @require      http://code.jquery.com/jquery-3.4.1.min.js
  9. // @grant        none
  10. // ==/UserScript==
  11.  
  12. /*Prevent context menu for misclicks*/
  13. document.addEventListener("contextmenu", function(e){
  14.     e.preventDefault();
  15. }, false);
  16.  
  17.  
  18.  
  19. /* Getting map dimensions */
  20. var baseX = window.document.FormBattleMap.mapoffsetx.value / 10
  21. var baseY = window.document.FormBattleMap.mapoffsety.value / 10
  22.  
  23. var gridSize = mapScale * 100
  24. /* Can't find the var, so have to do it the hard way */
  25. var width, height
  26. for (width = 0; ; width++){
  27.     if ($(`#map${width}x0DIV`).length == 0){
  28.         width--
  29.         break
  30.     }
  31. }
  32.  
  33. for (height = 0; ; height++){
  34.     if ($(`#map0x${height}DIV`).length == 0){
  35.         height--
  36.         break
  37.     }
  38. }
  39.  
  40. var screenWidth = (width + 1) * gridSize
  41. var screenHeight = (height + 1) * gridSize
  42. for (var i = 1; i <= width; i++){
  43.     if ((i + baseX) % 6 == 0){
  44.         if (i + baseX != 0)
  45.             drawLine('vertical', i * gridSize,'#3399ff')
  46.     }
  47.     else if ((i + baseX) % 6 == 3)
  48.         drawLine('vertical', i * gridSize,'#00ff00')
  49. }
  50.  
  51. for (i = 1; i <= height; i++){
  52.     if ((i + baseY) % 6 == 0){
  53.         if (i + baseY != 0)
  54.             drawLine('horizontal', i * gridSize, '#3399ff')
  55.     }
  56.     else if ((i + baseY) % 6 == 3)
  57.         drawLine('horizontal', i * gridSize, '#00ff00')
  58. }
  59.  
  60. function drawLine(direction, offset, color){
  61.     var node
  62.     if (direction == 'vertical'){
  63.         node = $.parseHTML(`<div style="font-size:0px; height:${screenHeight}px; width:1px; background-color:${color};position:absolute;left:${offset}px;top:0px"></div>`)
  64.         $('#map0x0DIV').parent().append(node)
  65.     }
  66.     else if (direction == 'horizontal'){
  67.         node = $.parseHTML(`<div style="font-size:0px; height:1px; width:${screenWidth}px; background-color:${color};position:absolute;top:${offset}px;left:0px"></div>`)
  68.         $('#map0x0DIV').parent().append(node)
  69.     }
  70. }
  71.  
  72. /* More grids! */
  73. $(document).ready(function(){
  74.     var fogOfWar = $('[id^="map"][id$="DIV"]:not(:has(img))')
  75.     fogOfWar.css("background-color", "#333333")
  76.     fogOfWar.append($($.parseHTML((`<img src="images/background_grid_${mapScale}0.gif" width="${100*mapScale}" height="${100*mapScale}" ondrag='return false;' onmousedown='return false;'>`))))
  77. })
Advertisement
Add Comment
Please, Sign In to add comment