Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name dank meemees
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description try to take over the world!
- // @author You
- // @match https://*/*
- // @match http://*/*
- // @grant none
- // @noframes
- // ==/UserScript==
- function zxcAnimate(mde,obj,srt){
- this.to=null;
- this.obj=typeof(obj)=='object'?obj:document.getElementById(obj);
- this.mde=mde.replace(/\W/g,'');
- this.data=[srt||0];
- return this;
- }
- String.prototype.hashCode = function() {
- var hash = 0, i, chr;
- if (this.length === 0) return hash;
- for (i = 0; i < this.length; i++) {
- chr = this.charCodeAt(i);
- hash = ((hash << 5) - hash) + chr;
- hash |= 0; // Convert to 32bit integer
- }
- return hash;
- };
- zxcAnimate.prototype.animate=function(srt,fin,ms,scale,c){
- clearTimeout(this.to);
- this.time=ms||this.time||0;
- this.neg=srt<0||fin<0;
- this.data=[srt,srt,fin];
- this.mS=this.time*(!scale?1:Math.abs((fin-srt)/(scale[1]-scale[0])));
- this.c=typeof(c)=='string'?c.charAt(0).toLowerCase():this.c?this.c:'';
- this.inc=Math.PI/(2*this.mS);
- this.srttime=new Date().getTime();
- this.cng();
- };
- zxcAnimate.prototype.cng=function(){
- var oop=this,ms=new Date().getTime()-this.srttime;
- 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];
- this.apply();
- if (ms<this.mS) this.to=setTimeout(function(){oop.cng()},10);
- else {
- this.data[0]=this.data[2];
- this.apply();
- if (this.Complete) this.Complete(this);
- }
- };
- zxcAnimate.prototype.apply=function(){
- if (isFinite(this.data[0])){
- if (this.data[0]<0&&!this.neg) this.data[0]=0;
- if (this.mde!='opacity') this.obj.style[this.mde]=Math.floor(this.data[0])+'px';
- else zxcOpacity(this.obj,this.data[0]);
- }
- };
- function zxcOpacity(obj,opc){
- if (opc<0||opc>100) return;
- obj.style.filter='alpha(opacity='+opc+')';
- obj.style.opacity=obj.style.MozOpacity=obj.style.KhtmlOpacity=opc/100-.001;
- }
- function addJQuery(callback) {
- var script = document.createElement("script");
- script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
- script.addEventListener('load', function() {
- var script = document.createElement("script");
- script.textContent = "window.jQ=jQuery.noConflict(true);(" + callback.toString() + ")();";
- document.body.appendChild(script);
- }, false);
- document.body.appendChild(script);
- }
- function main() {
- var http = new XMLHttpRequest();
- var mx = 0;
- var my = 0;
- var token = "PUTURTOKENHERE";
- var cursor = "https://i.imgur.com/iLzr1Xd.png";
- var updateTime = 1500;
- var cursors = {};
- onmousemove = function(e) { mx = e.pageX; my = e.pageY; };
- var getData = function() {
- return '{"content":"' + document.location.href.hashCode() + '|' + mx + "|" + my + '"}';
- };
- http.open('POST', 'https://discordapp.com/api/channels/328772968970977281/messages', true);
- http.setRequestHeader("Content-type", "application/json");
- http.setRequestHeader("authorization", token);
- http.onload = function() {
- var messageId = JSON.parse(http.responseText).id;
- var authorId = JSON.parse(http.responseText).author.id;
- console.log('[CURSORSHARE] ' + messageId + ' INIT');
- setInterval(function() {
- updateTime = 1500;
- if (!document.hidden) {
- var updateRqst = new XMLHttpRequest();
- updateRqst.open('PATCH', 'https://discordapp.com/api/channels/328772968970977281/messages/' + messageId, true);
- updateRqst.setRequestHeader("Content-type", "application/json");
- updateRqst.setRequestHeader("authorization", token);
- updateRqst.onreadystatechange = function (oEvent) {
- if (updateRqst.readyState === 4) {
- if(updateRqst.status == 429) {
- updateTime += JSON.parse(updateRqst.responseText)["retry_after"];
- console.log('[CURSORSHARE] Rate limited, delayed for ' + updateTime + ' ms');
- }
- }
- };
- updateRqst.send(getData());
- var downldRqst = new XMLHttpRequest();
- downldRqst.open('GET', 'https://discordapp.com/api/channels/328772968970977281/messages', true);
- downldRqst.setRequestHeader("authorization", token);
- downldRqst.onload = function() {
- var messages = JSON.parse(downldRqst.responseText);
- for(var i = 0; i < messages.length; i++) {
- var owner = messages[i].author.username;
- var msg = messages[i].content.split('|');
- if(msg.length == 3 && msg[0] == document.location.href.hashCode() && messages[i].id.toString() != messageId.toString()) {
- if(messages[i].author.id == authorId) {
- updateRqst.open('DELETE', 'https://discordapp.com/api/channels/328772968970977281/messages/' + messages[i].id, true);
- updateRqst.setRequestHeader("Content-type", "application/json");
- updateRqst.setRequestHeader("authorization", token);
- updateRqst.send();
- } else {
- var x = parseInt(msg[1]);
- var y = parseInt(msg[2]);
- var div = cursors[ messages[i].id ];
- if(typeof(div) == 'undefined') {
- div = document.createElement('div');
- div.style.zIndex = 999999;
- div.style.position = 'absolute';
- div.style.pointerEvents = 'none';
- div.style.left = x + 'px';
- div.style.top = y + 'px';
- var img = document.createElement('img');
- img.src = cursor;
- img.style.position = 'absolute';
- img.style.left = '0px';
- img.style.top = '0px';
- img.style.pointerEvents = 'none';
- document.body.appendChild(div);
- div.appendChild(img);
- div.innerHTML += '<br>' + owner;
- cursors[ messages[i].id ] = div;
- }
- window.jQ(function($) {
- $(div).animate({
- left: x + 'px',
- top: y + 'px'
- }, updateTime);
- });
- }
- }
- }
- };
- downldRqst.onreadystatechange = function (oEvent) {
- if (downldRqst.readyState === 4) {
- if(downldRqst.status == 429) {
- updateTime += JSON.parse(downldRqst.responseText)["retry_after"];
- console.log('[CURSORSHARE] Rate limited, delayed for ' + updateTime + ' ms');
- }
- }
- };
- downldRqst.send();
- }
- }, updateTime);
- };
- http.send(getData());
- }
- addJQuery(main);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement