Advertisement
URBAN420NETWORK

Untitled

Jun 26th, 2017
438
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.24 KB | None | 0 0
  1. // ==UserScript==
  2. // @name dank meemees
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description try to take over the world!
  6. // @author You
  7. // @match https://*/*
  8. // @match http://*/*
  9. // @grant none
  10. // @noframes
  11. // ==/UserScript==
  12.  
  13. function zxcAnimate(mde,obj,srt){
  14. this.to=null;
  15. this.obj=typeof(obj)=='object'?obj:document.getElementById(obj);
  16. this.mde=mde.replace(/\W/g,'');
  17. this.data=[srt||0];
  18. return this;
  19. }
  20.  
  21. String.prototype.hashCode = function() {
  22. var hash = 0, i, chr;
  23. if (this.length === 0) return hash;
  24. for (i = 0; i < this.length; i++) {
  25. chr = this.charCodeAt(i);
  26. hash = ((hash << 5) - hash) + chr;
  27. hash |= 0; // Convert to 32bit integer
  28. }
  29. return hash;
  30. };
  31.  
  32. zxcAnimate.prototype.animate=function(srt,fin,ms,scale,c){
  33. clearTimeout(this.to);
  34. this.time=ms||this.time||0;
  35. this.neg=srt<0||fin<0;
  36. this.data=[srt,srt,fin];
  37. this.mS=this.time*(!scale?1:Math.abs((fin-srt)/(scale[1]-scale[0])));
  38. this.c=typeof(c)=='string'?c.charAt(0).toLowerCase():this.c?this.c:'';
  39. this.inc=Math.PI/(2*this.mS);
  40. this.srttime=new Date().getTime();
  41. this.cng();
  42. };
  43.  
  44. zxcAnimate.prototype.cng=function(){
  45. var oop=this,ms=new Date().getTime()-this.srttime;
  46. this.data[0]=(this.c=='s')?(this.data[2]-this.data[1])*Math.sin(this.inc*ms)+this.data[1]:(this.c=='c')?this.data[2]-(this.data[2]-this.data[1])*Math.cos(this.inc*ms):(this.data[2]-this.data[1])/this.mS*ms+this.data[1];
  47. this.apply();
  48. if (ms<this.mS) this.to=setTimeout(function(){oop.cng()},10);
  49. else {
  50. this.data[0]=this.data[2];
  51. this.apply();
  52. if (this.Complete) this.Complete(this);
  53. }
  54. };
  55.  
  56. zxcAnimate.prototype.apply=function(){
  57. if (isFinite(this.data[0])){
  58. if (this.data[0]<0&&!this.neg) this.data[0]=0;
  59. if (this.mde!='opacity') this.obj.style[this.mde]=Math.floor(this.data[0])+'px';
  60. else zxcOpacity(this.obj,this.data[0]);
  61. }
  62. };
  63.  
  64. function zxcOpacity(obj,opc){
  65. if (opc<0||opc>100) return;
  66. obj.style.filter='alpha(opacity='+opc+')';
  67. obj.style.opacity=obj.style.MozOpacity=obj.style.KhtmlOpacity=opc/100-.001;
  68. }
  69.  
  70. function addJQuery(callback) {
  71. var script = document.createElement("script");
  72. script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
  73. script.addEventListener('load', function() {
  74. var script = document.createElement("script");
  75. script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
  76. document.body.appendChild(script);
  77. }, false);
  78. document.body.appendChild(script);
  79. }
  80.  
  81. function main() {
  82. var mx = 0;
  83. var my = 0;
  84.  
  85. var cursor = "https://i.imgur.com/iLzr1Xd.png";
  86. var cursors = {};
  87.  
  88. onmousemove = function(e) { mx = e.pageX; my = e.pageY; };
  89. var getData = function() {
  90. return document.location.href.hashCode() + '|' + mx + "|" + my;
  91. };
  92.  
  93. var ws = new WebSocket("ws://localhost:25666");
  94. var running = false;
  95.  
  96. ws.onopen = function () {
  97. running = true;
  98. };
  99.  
  100. setInterval(function() {
  101. if(running)
  102. ws.send(getData());
  103. }, 50);
  104.  
  105. ws.onmessage = function (evt) {
  106. var received_msg = evt.data;
  107. var messages = received_msg.split(';');
  108. for(var i = 0; i < messages.length; i++) {
  109. var msg = messages[i].split('|');
  110. if(msg.length == 3 && msg[0] == document.location.href.hashCode()) {
  111. var x = parseInt(msg[1]);
  112. var y = parseInt(msg[2]);
  113. var div = cursors[ i ];
  114. if(typeof(div) == 'undefined') {
  115. div = document.createElement('div');
  116. div.style.zIndex = 999999;
  117. div.style.position = 'absolute';
  118. div.style.pointerEvents = 'none';
  119. div.style.left = x + 'px';
  120. div.style.top = y + 'px';
  121.  
  122. var img = document.createElement('img');
  123. img.src = cursor;
  124. img.style.position = 'absolute';
  125. img.style.left = '0px';
  126. img.style.top = '0px';
  127. img.style.pointerEvents = 'none';
  128.  
  129. document.body.appendChild(div);
  130. div.appendChild(img);
  131. div.innerHTML += '<br>cursordude';
  132. cursors[ i ] = div;
  133. }
  134.  
  135. window.jQ(function($) {
  136. $(div).animate({
  137. left: x + 'px',
  138. top: y + 'px'
  139. }, 50);
  140. });
  141. }
  142. }
  143. };
  144.  
  145. ws.onclose = function () {
  146. running = false;
  147. alert("Connection is closed...");
  148. };
  149. }
  150.  
  151. addJQuery(main);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement