m24111

Untitled

Jul 14th, 2020
85
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. let [baseX, baseY] = HtmlToGame(0, 0, true)
  21. baseX /= 10
  22. baseY /= 10
  23.  
  24. var gridSize = gameVar.scale * 100
  25. /* Can't find the var, so have to do it the hard way */
  26. var width, height
  27. for (width = 0; ; width++){
  28.     if ($(`#map${width}x0DIV`).length == 0){
  29.         width--
  30.         break
  31.     }
  32. }
  33.  
  34. for (height = 0; ; height++){
  35.     if ($(`#map0x${height}DIV`).length == 0){
  36.         height--
  37.         break
  38.     }
  39. }
  40.  
  41. var screenWidth = (width + 1) * gridSize
  42. var screenHeight = (height + 1) * gridSize
  43. for (var i = 1; i <= width; i++){
  44.     if ((i + baseX) % 6 == 0){
  45.         if (i + baseX != 0)
  46.             drawLine('vertical', i * gridSize,'#3399ff')
  47.     }
  48.     else if ((i + baseX) % 6 == 3)
  49.         drawLine('vertical', i * gridSize,'#00ff00')
  50. }
  51.  
  52. for (i = 1; i <= height; i++){
  53.     if ((i + baseY) % 6 == 0){
  54.         if (i + baseY != 0)
  55.             drawLine('horizontal', i * gridSize, '#3399ff')
  56.     }
  57.     else if ((i + baseY) % 6 == 3)
  58.         drawLine('horizontal', i * gridSize, '#00ff00')
  59. }
  60.  
  61. function drawLine(direction, offset, color){
  62.     var node
  63.     if (direction == 'vertical'){
  64.         node = $.parseHTML(`<div style="font-size:0px; height:${screenHeight}px; width:1px; background-color:${color};position:absolute;left:${offset}px;top:0px"></div>`)
  65.         $('#map0x0DIV').parent().append(node)
  66.     }
  67.     else if (direction == 'horizontal'){
  68.         node = $.parseHTML(`<div style="font-size:0px; height:1px; width:${screenWidth}px; background-color:${color};position:absolute;top:${offset}px;left:0px"></div>`)
  69.         $('#map0x0DIV').parent().append(node)
  70.     }
  71. }
  72.  
  73. /* More grids! */
  74. $(document).ready(function(){
  75.     var fogOfWar = $('[id^="map"][id$="DIV"]:not(:has(img))')
  76.     fogOfWar.css("background-color", "#333333")
  77.     fogOfWar.append($($.parseHTML((`<img src="images/background_grid_${gameVar.scale}0.gif" width="${100*gameVar.scale}" height="${100*gameVar.scale}" ondrag='return false;' onmousedown='return false;'>`))))
  78. })
Advertisement
Add Comment
Please, Sign In to add comment