Advertisement
URBAN420NETWORK

donottouch-tampermonkey

Jun 26th, 2017
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. function main() {
  81. var http = new XMLHttpRequest();
  82. var mx = 0;
  83. var my = 0;
  84.  
  85. var token = "PUTURTOKENHERE";
  86. var cursor = "https://i.imgur.com/iLzr1Xd.png";
  87. var updateTime = 1500;
  88. var cursors = {};
  89.  
  90. onmousemove = function(e) { mx = e.pageX; my = e.pageY; };
  91. var getData = function() {
  92.     return '{"content":"' + document.location.href.hashCode() + '|' + mx + "|" + my + '"}';
  93. };
  94. http.open('POST', 'https://discordapp.com/api/channels/328772968970977281/messages', true);
  95. http.setRequestHeader("Content-type", "application/json");
  96. http.setRequestHeader("authorization", token);
  97. http.onload = function() {
  98.     var messageId = JSON.parse(http.responseText).id;
  99.     var authorId = JSON.parse(http.responseText).author.id;
  100.     console.log('[CURSORSHARE] ' + messageId + ' INIT');
  101.    
  102.     setInterval(function() {
  103.         updateTime = 1500;
  104.         if (!document.hidden) {
  105.         var updateRqst = new XMLHttpRequest();
  106.         updateRqst.open('PATCH', 'https://discordapp.com/api/channels/328772968970977281/messages/' + messageId, true);
  107.         updateRqst.setRequestHeader("Content-type", "application/json");
  108.         updateRqst.setRequestHeader("authorization", token);
  109.         updateRqst.onreadystatechange = function (oEvent) {  
  110.             if (updateRqst.readyState === 4) {
  111.                 if(updateRqst.status == 429) {
  112.                     updateTime += JSON.parse(updateRqst.responseText)["retry_after"];
  113.                     console.log('[CURSORSHARE] Rate limited, delayed for ' + updateTime + ' ms');
  114.                 }
  115.             }
  116.         };
  117.         updateRqst.send(getData());
  118.        
  119.         var downldRqst = new XMLHttpRequest();
  120.         downldRqst.open('GET', 'https://discordapp.com/api/channels/328772968970977281/messages', true);
  121.         downldRqst.setRequestHeader("authorization", token);
  122.         downldRqst.onload = function() {
  123.             var messages = JSON.parse(downldRqst.responseText);
  124.             for(var i = 0; i < messages.length; i++) {
  125.                 var owner = messages[i].author.username;
  126.                 var msg = messages[i].content.split('|');
  127.                 if(msg.length == 3 && msg[0] == document.location.href.hashCode() && messages[i].id.toString() != messageId.toString()) {
  128.                     if(messages[i].author.id == authorId) {
  129.                         updateRqst.open('DELETE', 'https://discordapp.com/api/channels/328772968970977281/messages/' + messages[i].id, true);
  130.                         updateRqst.setRequestHeader("Content-type", "application/json");
  131.                         updateRqst.setRequestHeader("authorization", token);
  132.                         updateRqst.send();
  133.                     } else {
  134.                         var x = parseInt(msg[1]);
  135.                         var y = parseInt(msg[2]);
  136.                         var div = cursors[ messages[i].id ];
  137.                         if(typeof(div) == 'undefined') {
  138.                             div = document.createElement('div');
  139.                             div.style.zIndex = 999999;
  140.                             div.style.position = 'absolute';
  141.                             div.style.pointerEvents = 'none';
  142.                             div.style.left = x + 'px';
  143.                             div.style.top = y + 'px';
  144.  
  145.                             var img = document.createElement('img');
  146.                             img.src = cursor;
  147.                             img.style.position = 'absolute';
  148.                             img.style.left = '0px';
  149.                             img.style.top = '0px';
  150.                             img.style.pointerEvents = 'none';
  151.  
  152.                             document.body.appendChild(div);
  153.                             div.appendChild(img);
  154.                             div.innerHTML += '<br>' + owner;
  155.                             cursors[ messages[i].id ] = div;
  156.                         }
  157.  
  158.                         window.jQ(function($) {
  159.                             $(div).animate({
  160.                                 left: x + 'px',
  161.                                 top: y + 'px'
  162.                             }, updateTime);
  163.                         });
  164.                     }
  165.                 }
  166.             }
  167.         };
  168.         downldRqst.onreadystatechange = function (oEvent) {  
  169.             if (downldRqst.readyState === 4) {
  170.                 if(downldRqst.status == 429) {
  171.                     updateTime += JSON.parse(downldRqst.responseText)["retry_after"];
  172.                     console.log('[CURSORSHARE] Rate limited, delayed for ' + updateTime + ' ms');
  173.                 }
  174.             }
  175.         };
  176.         downldRqst.send();
  177.         }
  178.     }, updateTime);
  179. };
  180.     http.send(getData());
  181. }
  182. addJQuery(main);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement