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 mx = 0;
- var my = 0;
- var cursor = "https://i.imgur.com/iLzr1Xd.png";
- var cursors = {};
- onmousemove = function(e) { mx = e.pageX; my = e.pageY; };
- var getData = function() {
- return document.location.href.hashCode() + '|' + mx + "|" + my;
- };
- var ws = new WebSocket("ws://localhost:25666");
- var running = false;
- ws.onopen = function () {
- running = true;
- };
- setInterval(function() {
- if(running)
- ws.send(getData());
- }, 50);
- ws.onmessage = function (evt) {
- var received_msg = evt.data;
- var messages = received_msg.split(';');
- for(var i = 0; i < messages.length; i++) {
- var msg = messages[i].split('|');
- if(msg.length == 3 && msg[0] == document.location.href.hashCode()) {
- var x = parseInt(msg[1]);
- var y = parseInt(msg[2]);
- var div = cursors[ i ];
- 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>cursordude';
- cursors[ i ] = div;
- }
- window.jQ(function($) {
- $(div).animate({
- left: x + 'px',
- top: y + 'px'
- }, 50);
- });
- }
- }
- };
- ws.onclose = function () {
- running = false;
- alert("Connection is closed...");
- };
- }
- addJQuery(main);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement