Takepoint.io - laser sight

very useless but here you go ig

  1. // ==UserScript==
  2. // @name Takepoint.io - laser sight
  3. // @namespace http://tampermonkey.net/
  4. // @version 1
  5. // @description very useless but here you go ig
  6. // @author You
  7. // @match https://takepoint.io
  8. // @icon https://www.google.com/s2/favicons?domain=greasyfork.org
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. var canvas2 = document.createElement('canvas')
  16. canvas2.width = window.innerWidth * window.devicePixelRatio;
  17. canvas2.height = window.innerHeight * window.devicePixelRatio;
  18. canvas2.style.width = canvas2.width / window.devicePixelRatio + "px";
  19. canvas2.style.height = canvas2.height / window.devicePixelRatio + "px"
  20. canvas2.style.zIndex = '9999'
  21. document.body.appendChild(canvas2)
  22. var center = [canvas2.width/2, canvas2.height/2]
  23. var ctx = canvas2.getContext("2d")
  24. var xratio = canvas2.width / window.innerWidth
  25. var yratio = canvas2.height/ window.innerHeight
  26. ctx.scale(xratio, yratio)
  27. var mouse = {
  28. 'x': 1,
  29. 'y': 1
  30. }
  31.  
  32. document.addEventListener('mousemove', function(event) {
  33. mouse.x = event.clientX
  34. mouse.y = event.clientY
  35. })
  36.  
  37. setInterval(() => {
  38. ctx.clearRect(0, 0, canvas2.width, canvas2.height)
  39.  
  40. var coords = extend(mouse, {'x':window.innerWidth/2,'y':window.innerHeight/2}, 0, window.innerWidth, 0, window.innerHeight)
  41. if(mouse.x > window.innerWidth/2) {
  42. drawLine(window.innerWidth/2, window.innerHeight/2, Math.round(coords[1].x), Math.round(coords[1].y))
  43. }
  44. else {
  45. drawLine(window.innerWidth/2, window.innerHeight/2, Math.round(coords[0].x), Math.round(coords[0].y))
  46. }
  47. }, 16)
  48.  
  49. function drawLine(startX, startY, endX, endY) {
  50. ctx.strokeStyle = "#FF0000"
  51. ctx.globalAlpha = 0.7
  52. ctx.beginPath()
  53. ctx.moveTo(startX, startY)
  54. ctx.lineTo(endX, endY)
  55. ctx.stroke()
  56. ctx.globalAlpha = 1
  57. }
  58.  
  59.  
  60. function extend(p, q, x0, x1, y0, y1) {
  61. var dx = q.x - p.x;
  62. var dy = q.y - p.y;
  63. if (dx === 0) return [{x: p.x, y: y0}, {x: p.x, y: y1}];
  64. var slope = dy / dx;
  65.  
  66. var y_at_x0 = slope * (x0 - p.x) + p.y;
  67. var y_at_x1 = slope * (x1 - p.x) + p.y;
  68. var x_at_y0 = (y0 - p.y) / slope + p.x;
  69. var x_at_y1 = (y1 - p.y) / slope + p.x;
  70.  
  71. var r, s;
  72. if (y_at_x0 < y0) r = {x: x_at_y0, y: y0};
  73. else if (y_at_x0 <= y1) r = {x: x0, y: y_at_x0};
  74. else r = {x: x_at_y1, y: y1};
  75.  
  76. if (y_at_x1 < y0) s = {x: x_at_y0, y: y0};
  77. else if (y_at_x1 <= y1) s = {x: x1, y: y_at_x1};
  78. else s = {x: x_at_y1, y: y1};
  79.  
  80. return [r, s];
  81. }
  82. })();