Skip to content

Instantly share code, notes, and snippets.

@agentlame
Created October 25, 2014 12:37
Show Gist options
  • Save agentlame/f462488755071a9ad7e6 to your computer and use it in GitHub Desktop.
Save agentlame/f462488755071a9ad7e6 to your computer and use it in GitHub Desktop.
Flying Snoo for reddit by @LowSociety -- You'll need Tampermonkey (Chrome) or Greasemonkey (Firefox) then click 'raw' to install it. It only works at the bottom of user pages, but that can be easily changed. Bonus: this is the version where you can kill Snoo. >:)
// ==UserScript==
// @name Flying Snoo
// @namespace http://reddit.com/user/LowSociety
// @version 1.0.2
// @description snoo + fly
// @match *://*.reddit.com/*
// @copyright 2014+, LowSociety
// ==/UserScript==
$(".profile-page .footer-parent").click(function() {
var background = $(this).css("background");
var width = 87,
height = 145;
var floater = $("<div></div>").css({
height : height + "px",
width : width + "px",
background : "url(http://c.thumbs.redditmedia.com/7U0yjjycFy9MC5ht.png)",
position : "absolute",
top : $(this).offset().top + "px",
left : (($(window).width() * 0.49) - (width/2)) + "px",
zIndex : 999
}).appendTo("body");
var documentHeight = $(document).height(),
documentWidth = $(document).width(),
iterations = 0,
wind = 0,
oldTop = floater.position().top,
oldLeft = floater.position().left;
var interval = null;
var startInterval = function() {
interval = window.setInterval(function() {
var newTop = Math.max(0, (oldTop - ((documentHeight)*0.001)));
if(iterations % 50 == 0) {
wind = ((Math.random() * 200)-100) * 0.02;
}
newLeft = Math.min(documentWidth - width,Math.max(0, oldLeft + wind));
floater.css({
top : newTop + "px",
left : newLeft + "px"
});
iterations++;
if(newTop <= 0) {
window.clearInterval(interval);
interval = null;
}
oldTop = newTop;
oldLeft = newLeft;
}, 50);
}
floater.mousedown(function(e) {
if(interval != null) {
window.clearInterval(interval);
interval = null;
}
floater.data("offsetX", e.offsetX);
floater.data("offsetY", e.offsetY);
var dragEvent = function(e) {
var offsetX = floater.data("offsetX") || 0,
offsetY = floater.data("offsetY") || 0;
oldLeft = (e.pageX - offsetX);
oldTop = (e.pageY - offsetY);
floater.css({
"left" : oldLeft + "px",
"top" : oldTop + "px"
});
}
var releaseEvent = function() {
if(interval == null)
startInterval();
$(document).unbind("mousemove", dragEvent);
$(document).unbind("mouseup", releaseEvent);
}
$(document).bind("mousemove", dragEvent).bind("mouseup", releaseEvent);
}).dblclick(function() {
if(interval != null) {
window.clearInterval(interval);
interval = null;
}
$(this).unbind("mousedown");
$(this).css("background","url(http://a.thumbs.redditmedia.com/P0tVLpH52smMNXPN.png)");
interval = window.setInterval(function() {
var newTop = oldTop + Math.max(50,Math.min(10,oldTop*0.05));
floater.css({
"top" : newTop + "px"
});
oldTop = newTop;
if(oldTop + height >= documentHeight) {
window.clearInterval(interval);
interval = null;
floater.css({
"top" : (documentHeight-height) + "px"
});
floater.css("background","url(http://d.thumbs.redditmedia.com/tIFOjQQ5pPahJKP-.png)");
}
},50);
});
$(this).css("background","transparent");
startInterval();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment